Skip to content

Conversation

@henkka
Copy link
Contributor

@henkka henkka commented Nov 27, 2025

This PR fixes a bug in the recently introduced aws_billing_view resource (initially added in #45097) where data_filter_expression configurations were being silently dropped during creation and update, leading to state inconsistencies.

Currently, if a user attempts to configure data_filter_expression (e.g., filtering by tags or dimensions), the generic flex reflection helpers fail to map the Terraform ListNestedBlock to the corresponding AWS SDK struct.

This results in two issues:

  • Silent Data Loss: An empty DataFilterExpression struct is sent to the AWS API.
  • State Inconsistency: Because the API returns no filter data (since none was sent), Terraform detects a diff between the plan (1 block) and the state (0 blocks) during the read phase.
resource "aws_billing_view" "this" {
  data_filter_expression {
    tags {
      key    = "tenant"
      values = ["example"]
    }
  }
}

produces

╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to aws_billing_view.this, provider "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected new value:
│ .data_filter_expression: block count changed from 1 to 0.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

To fix the issue, this PR introduces manual expansion and flattening logic for the data_filter_expression field.

  • Expansion: Added expandDataFilterExpression helper to manually extract values from the Terraform ListNestedBlock (taking the 0th index) and construct the *awstypes.DataFilterExpression struct required by the AWS SDK.

  • Flattening: Added flattenDataFilterExpression helper to correctly map the AWS SDK response back into the Terraform state structure.

@henkka henkka requested a review from a team as a code owner November 27, 2025 05:33
@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 Nov 27, 2025

✅ 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/billing Issues and PRs that pertain to the billing service. size/L Managed by automation to categorize the size of a PR. labels Nov 27, 2025
@henkka henkka changed the title resource/aws_billing_view: Fix data_filter_expression handling r/aws_billing_view: Fix data_filter_expression handling Nov 27, 2025
@jar-b jar-b added regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. and removed needs-triage Waiting for first response or review from a maintainer. labels Dec 1, 2025
@github-actions github-actions bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/billing Issues and PRs that pertain to the billing service. size/L 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.

2 participants