hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.65k stars 9.03k forks source link

Provider produced inconsistent final plan when using a step function #23671

Open Octogonapus opened 2 years ago

Octogonapus commented 2 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

Terraform v1.1.7
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.74.3
+ provider registry.terraform.io/hashicorp/external v2.2.0
+ provider registry.terraform.io/hashicorp/local v2.2.2
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0

Affected Resource(s)

Terraform Configuration Files

I have been trying to produce a MWE but it is tricky to boil this one down and I haven't been able to do it so far. We have some step functions that use this module:

module "step_function" {
  source = "terraform-aws-modules/step-functions/aws"

  name = random_id.test_db_step_function.hex
  definition = templatefile(
    "${path.module}/definition.json", { ... }
  )
  service_integrations = {
    lambda = {
      lambda = [...]
    }
    stepfunction_Sync = {
      stepfunction          = [...]
      stepfunction_Wildcard = [...]
      events                = [...]
    }
  }
  attach_policy = true
  policy        = aws_iam_policy.policy.arn
  type          = "STANDARD"
}

Expected Behavior

No inconsistent final plan error.

Actual Behavior

╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for module.db_backup_tester.module.predicate-db_deleted.module.step_function.aws_sfn_state_machine.this[0] to include new values learned so far during apply, provider
│ "registry.terraform.io/hashicorp/aws" produced an invalid new value for .tags_all: new element "Name" has appeared.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for module.db_backup_tester.module.predicate-db_status.module.step_function.aws_sfn_state_machine.this[0] to include new values learned so far during apply, provider
│ "registry.terraform.io/hashicorp/aws" produced an invalid new value for .tags_all: new element "Name" has appeared.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

I guess Terraform lost track of the tag added here.

Steps to Reproduce

The problem occurs when running terraform apply.

It's important to note that applying twice works around the issue. i.e.:

  1. terraform plan and terraform apply
  2. Get the plan error
  3. terraform plan and terraform apply
  4. Success

Important Factoids

References

ajoga commented 2 years ago

Could it be related to https://github.com/hashicorp/terraform-provider-aws/issues/19583 ? TLDR: computed value in tags_all has an issue, some workaround are offered in linked issue.

github-actions[bot] commented 3 weeks ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!