Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Constant diff on update or error on creation of aws_ce_cost_category #38215

Open
ohookins opened this issue Jul 2, 2024 · 1 comment
Labels
bug Addresses a defect in current functionality. service/ce Issues and PRs that pertain to the ce service.

Comments

@ohookins
Copy link

ohookins commented Jul 2, 2024

Terraform Core Version

1.8.4

AWS Provider Version

5.50.0

Affected Resource(s)

  • aws_ce_cost_category

Expected Behavior

A new creation of the resource completes without error, and updates complete without a constant diff.

Actual Behavior

Working around the constant diff prevents the resource being created in the first place. Forming the resource so the resource can be created properly results in a constant diff on re-plan/re-apply.

Relevant Error/Panic Output Snippet

│ Error: updating Cost Explorer Cost Category (arn:aws:ce::xxxx:costcategory/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx): operation error Cost Explorer: UpdateCostCategoryDefinition, https response error StatusCode: 400, RequestID: xxxx, api error ValidationException: Failed to update Cost Category: Invalid INHERITED_VALUE rule defined. Rule and Value attributes must be null

│   with aws_ce_cost_category.accounts,
│   on ce-cost-category-accounts.tf line 4, in resource "aws_ce_cost_category" "accounts":
│    4: resource "aws_ce_cost_category" "accounts" {

This is the error that we get if we attempt to fix the constant diff, which breaks creation or updating of the resource.

Terraform Configuration Files

resource "aws_ce_cost_category" "accounts" {
  name            = "AccountName"
  rule_version    = "CostCategoryExpression.v1"

  rule {
    type = "INHERITED_VALUE"
    inherited_value {
      dimension_name = "LINKED_ACCOUNT_NAME"
    }
  }
}

This works, but results in a constant diff on re-applies. This suggests an empty rule {} block (within the outer rule block) is required to prevent the constant diff.

  # aws_ce_cost_category.accounts will be updated in-place
  ~ resource "aws_ce_cost_category" "accounts" {
        id              = "arn:aws:ce::xxxx:costcategory/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        name            = "AccountName"
        tags            = {}
        # (6 unchanged attributes hidden)

      - rule {
          - type  = "INHERITED_VALUE" -> null
            # (1 unchanged attribute hidden)

          - inherited_value {
              - dimension_name = "LINKED_ACCOUNT_NAME" -> null
                # (1 unchanged attribute hidden)
            }

          - rule {
            }
        }
      + rule {
          + type  = "INHERITED_VALUE"
            # (1 unchanged attribute hidden)

          + inherited_value {
              + dimension_name = "LINKED_ACCOUNT_NAME"
                # (1 unchanged attribute hidden)
            }
        }
    }

Indeed, if you supply the empty rule {} block where the diff suggests, this allows a subsequent plan to proceed without any diff for this resource. However, creating the resource anew with the empty rule {} block in place leads to the error as pasted above.

Steps to Reproduce

  1. Create a aws_ce_cost_category resource as above, with the empty rule {} block in place.
  2. Plan/apply. It will fail to create with the error as mentioned above.
  3. Remove the empty rule {} block. The resource will create as expected.
  4. Plan/apply, it will show a constant diff on every plan now.

Debug Output

N/A

Panic Output

N/A

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@ohookins ohookins added the bug Addresses a defect in current functionality. label Jul 2, 2024
Copy link

github-actions bot commented Jul 2, 2024

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/ce Issues and PRs that pertain to the ce service. label Jul 2, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 2, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/ce Issues and PRs that pertain to the ce service.
Projects
None yet
Development

No branches or pull requests

2 participants