Terraform-provider-aws: Creating a new aws_config_configuration_aggregator appears to not add to state if name has uppercase letters

Created on 25 Apr 2019  ·  4Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.13
+ provider.aws v2.7.0

Affected Resource(s)

Terraform Configuration Files

data "aws_caller_identity" "current" {}

resource "aws_config_configuration_aggregator" "account" {
  name = "MyAccountAggregator"

  account_aggregation_source {
    all_regions = true
    account_ids = ["${data.aws_caller_identity.current.account_id}"]
  }
}

Expected Behavior

  • ✅ Aggregator created successfully
  • ✅ New resource saved in state, with no changes on a subsequent apply

Actual Behavior

  • ✅ Aggregator created successfully
  • ❌ Terraform appears to not be aware of the new resource when running a subsequent apply

Steps to Reproduce

  1. Run terraform apply
  2. Observe that the new aggregator now exists at https://console.aws.amazon.com/config/home?#/aggregators/view
  3. Run terraform apply again
  4. Observe that Terraform creates the resource again, with no knowledge of the resource previously created
  5. Repeat the last two steps as much as you like
  6. Run terraform import aws_config_configuration_aggregator.account MyAccountAggregator
  7. Run terraform apply again
  8. Observe that the aggregator is now no longer planned for creation

Important Factoids

I haven't redacted any sensitive tokens from the debug output so I haven't got the entire thing to post, but I did save debug output for each run and did a diff. This stood out:

[DEBUG] plugin.terraform-provider-aws_v2.7.0_x4: [WARN] No such configuration aggregator (myaccountaggregator), removing from state

...which led to me to try the same exercise again, with the name my-account-aggregator instead. This worked fine.

So it appears that:

  • aggregators using CamelCase in their names _do not_ get added to state on apply (but they _do_ on import)
  • aggregators using kebab-case in their names _do_ get added to state on apply
bug servicconfigservice servicsts

Most helpful comment

I have what I believe is a related issue:

resource "aws_config_configuration_aggregator" "account" {
  count = "${var.aws_account_id == "XXXXXXXXXXXX" ? 1 : 0}"
  name  = "XXXXXXXXXXXX"

  account_aggregation_source {
    account_ids = [
      for acct in var.non_security_member_accounts :
      acct.aws_account_id
    ]
    all_regions = true
  }
}

Execution plan results in:

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.config.aws_config_configuration_aggregator.account[0] will be updated in-place
  ~ resource "aws_config_configuration_aggregator" "account" {
        arn  = "arn:aws:config:us-west-2:XXXXXXXXXXXX:config-aggregator/config-aggregator-jhbprejd"
        id   = "XXXXXXXXXXXX"
        name = "XXXXXXXXXXXX"

      ~ account_aggregation_source {
          ~ account_ids = [
                "AAAAAAAAAAAA",
              - "BBBBBBBBBBBB",
              - "CCCCCCCCCCCC",
                "DDDDDDDDDDDD",
                "EEEEEEEEEEEE",
              + "BBBBBBBBBBBB",
            ]
            all_regions = true
            regions     = []
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

I did expect to see CCCCCCCCCCCC removed, as it's not part of the list I'm passing in to the variable. However, notice B is both added and removed. Attempting to apply results in:

Error: Provider produced inconsistent result after apply

When applying changes to
module.config.aws_config_configuration_aggregator.account[0], provider "aws"
produced an unexpected new value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

I believe this part of related state management problems for this resource.

All 4 comments

I actually run into Error: Provider produced inconsistent result after apply because of this.

I have what I believe is a related issue:

resource "aws_config_configuration_aggregator" "account" {
  count = "${var.aws_account_id == "XXXXXXXXXXXX" ? 1 : 0}"
  name  = "XXXXXXXXXXXX"

  account_aggregation_source {
    account_ids = [
      for acct in var.non_security_member_accounts :
      acct.aws_account_id
    ]
    all_regions = true
  }
}

Execution plan results in:

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.config.aws_config_configuration_aggregator.account[0] will be updated in-place
  ~ resource "aws_config_configuration_aggregator" "account" {
        arn  = "arn:aws:config:us-west-2:XXXXXXXXXXXX:config-aggregator/config-aggregator-jhbprejd"
        id   = "XXXXXXXXXXXX"
        name = "XXXXXXXXXXXX"

      ~ account_aggregation_source {
          ~ account_ids = [
                "AAAAAAAAAAAA",
              - "BBBBBBBBBBBB",
              - "CCCCCCCCCCCC",
                "DDDDDDDDDDDD",
                "EEEEEEEEEEEE",
              + "BBBBBBBBBBBB",
            ]
            all_regions = true
            regions     = []
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

I did expect to see CCCCCCCCCCCC removed, as it's not part of the list I'm passing in to the variable. However, notice B is both added and removed. Attempting to apply results in:

Error: Provider produced inconsistent result after apply

When applying changes to
module.config.aws_config_configuration_aggregator.account[0], provider "aws"
produced an unexpected new value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

I believe this part of related state management problems for this resource.

Same behavior is still present in version 3.2.0...

Terraform v0.12.29
+ provider.aws v3.2.0

still same problem with 3.7

Was this page helpful?
0 / 5 - 0 ratings