Skip to content

Fix/route53 resolver rule remove defaults#46928

Open
gaik180303 wants to merge 3 commits intohashicorp:mainfrom
gaik180303:fix/route53-resolver-rule-remove-defaults
Open

Fix/route53 resolver rule remove defaults#46928
gaik180303 wants to merge 3 commits intohashicorp:mainfrom
gaik180303:fix/route53-resolver-rule-remove-defaults

Conversation

@gaik180303
Copy link

Fix: Remove hardcoded defaults for port and protocol in aws_route53_resolver_rule target IP configuration

#41523

The aws_route53_resolver_rule resource previously hardcoded Default: 53 for port and Default: "Do53" for protocol in the target_ip block. This overrode the AWS API's conditional defaults. For example, the API automatically sets port to 443 when using DoH protocol and may auto-select DoH when the resolver endpoint only supports DoH. Because the provider always injected these defaults, it could lead to errors or incorrect behavior when the API expected different values.

Changes Made

internal/service/route53resolver/rule.go

  • Removed explicit Default values for port and protocol in the target_ip schema.
  • Replaced them with Optional: true and Computed: true so Terraform accepts values returned by the AWS API when users do not specify them.
  • Updated expandRuleTargetIPs to only send port to the AWS API when it is explicitly provided (vPort != 0). This prevents sending a zero value and allows the API to apply its own default.
  • Updated protocol handling so the field is only sent when explicitly set (vProtocol != ""), allowing the API to determine the correct protocol based on endpoint configuration.

internal/service/route53resolver/rule_test.go

  • Updated TestAccRoute53ResolverRule_forwardMultiProtocol to explicitly set "Do53" in the first step since the provider no longer injects a default.
  • Added TestAccRoute53ResolverRule_forwardAPIDefaults to verify that when port and protocol are omitted from configuration, the AWS API correctly assigns them. The test validates this using TestCheckResourceAttrSet.

Outcome

When port and protocol are omitted from the target_ip block, the AWS API now applies its own conditional defaults. This aligns the provider behavior with the AWS API, CLI, and SDKs and avoids incorrect overrides caused by hardcoded defaults.

@gaik180303 gaik180303 requested a review from a team as a code owner March 13, 2026 18:49
@github-actions
Copy link
Contributor

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 13, 2026

✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/route53resolver Issues and PRs that pertain to the route53resolver service. size/S Managed by automation to categorize the size of a PR. labels Mar 13, 2026
…lts for port and protocol in aws_route53_resolver_rule target_ip
@dosubot dosubot bot added the bug Addresses a defect in current functionality. label Mar 13, 2026
@jar-b jar-b added the breaking-change Introduces a breaking change in current functionality; usually deferred to the next major release. label Mar 13, 2026
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Introduces a breaking change in current functionality; usually deferred to the next major release. bug Addresses a defect in current functionality. service/route53resolver Issues and PRs that pertain to the route53resolver service. size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants