Skip to content

Conversation

@morremeyer
Copy link

what

This fixes the deprecation of the "name" attribute for the aws_region data source, adding a fallback for provider versions < 6.0.0.

why

To get rid of the deprecation notice and prepare for provider version 7.

references

Resolves #361.

This fixes the deprecation of the "name" attribute for the aws_region data source, adding a fallback for provider versions < 6.0.0.
@morremeyer morremeyer requested review from a team as code owners December 12, 2025 12:12
@coderabbitai
Copy link

coderabbitai bot commented Dec 12, 2025

📝 Walkthrough

Walkthrough

Addressed AWS provider v6+ deprecation warning by introducing a fallback mechanism in main.tf that prioritizes the region attribute over the deprecated name attribute when accessing the current AWS region.

Changes

Cohort / File(s) Summary
Region Attribute Deprecation Fix
main.tf
Introduced new local variable aws_region_name using try() to safely fall back from region to name attribute. Updated origin_shield_region calculation to reference local.aws_region_name instead of directly accessing deprecated data.aws_region.current[0].name. Added compatibility comments for AWS provider v6 migration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the try() fallback correctly prioritizes region over name for provider version compatibility
  • Confirm all references to the deprecated attribute have been migrated to use the new local variable
  • Validate that the fallback logic preserves intended behavior for both current and legacy AWS provider versions

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing the deprecation warning for the aws_region data source 'name' attribute, which directly matches the changeset.
Description check ✅ Passed The description explains what was changed (fixing 'name' deprecation with fallback), why (prepare for provider v7), and references the related issue #361, all aligned with the changes.
Linked Issues check ✅ Passed The PR successfully implements the requirement from issue #361 by adding a fallback mechanism using try() to handle the deprecated 'name' attribute in AWS provider v6+.
Out of Scope Changes check ✅ Passed All changes focus on fixing the aws_region data source deprecation warning, which is directly scoped to issue #361 requirements with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0710df3 and bca6961.

📒 Files selected for processing (1)
  • main.tf (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-31T11:46:57.218Z
Learnt from: jwadolowski
Repo: cloudposse/terraform-aws-cloudfront-s3-cdn PR: 340
File: main.tf:570-578
Timestamp: 2025-07-31T11:46:57.218Z
Learning: In terraform-aws-cloudfront-s3-cdn module, custom_origin_config in the custom_origins variable was always a required parameter, not optional. CloudFront origins require either custom_origin_config or s3_origin_config but not both, so null was never a valid value for custom_origin_config in custom origins.

Applied to files:

  • main.tf
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Summary
🔇 Additional comments (2)
main.tf (2)

104-104: origin_shield_region calculation correctly refactored to use fallback.

The update properly delegates to local.aws_region_name, eliminating the direct reference to the deprecated attribute while preserving the existing lookup behavior against origin_shield_region_fallback_map.


88-90: Fallback implementation correctly prioritizes new region attribute.

The try() approach properly handles AWS provider version compatibility by attempting the new region attribute first (v6.0.0+) and gracefully falling back to the deprecated name attribute for older versions. The explanatory comments clearly document the version constraint and removal timeline. No other references to the deprecated attribute exist in the configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mergify mergify bot added the triage Needs triage label Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage Needs triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws_region.current.name attribute is deprecated in version 6 of the AWS provider

1 participant