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.74k stars 9.1k forks source link

[Bug]: aws_chatbot_slack_channel_configuration produced an unexpected new value: .configuration_name was X, but now Y #38956

Open rwilliams3088 opened 3 weeks ago

rwilliams3088 commented 3 weeks ago

Terraform Core Version

1.6.1

AWS Provider Version

~> 5.0

Affected Resource(s)

aws_chatbot_slack_channel_configuration

Expected Behavior

If the name parameter changes, then either the resource should be updated with that new name or else the resource should be destroyed and recreated.

Actual Behavior

The resource name is left unmodified

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

variable "suffix" {}
variable "slack_team_id" {}
variable "slack_channel_id" {}

resource "aws_chatbot_slack_channel_configuration" "my_slack_channel" {
  configuration_name = "my-slack-channel-${var.suffix}"

  iam_role_arn          = aws_iam_role.my_slack_channel_chatbot_role.arn
  guardrail_policy_arns = [data.aws_iam_policy.ReadOnlyAccess.arn]

  slack_channel_id = var.slack_channel_id
  slack_team_id    = var.slack_team_id
}

resource "aws_iam_role" "my_slack_channel_chatbot_role" {
  name = "my-slack-channel-${var.suffix}"

  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Sid    = ""
        Principal = {
          Service = "ec2.amazonaws.com"
        }
      },
    ]
  })
}

data "aws_iam_policy" "ReadOnlyAccess" {
  name = "ReadOnlyAccess"
}

Steps to Reproduce

First, create an .tfvars file that supplies a valid slack_team_id slack_channel_id and sets suffix = "test"

Run terraform apply and confirm that the resources are successfully provisioned

Next, modify the .tfvars file and set suffix = "dev" (or whatever you prefer other than "test")

Run terraform apply again. Terraform will run successfully, but will spit out a warning (see Debug Output). Afterwards, the resource name will remain the same despite the value of suffix changing.

Debug Output

Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to
│ module.common.aws_chatbot_slack_channel_configuration.my_slack_channel,
│ provider "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an
│ unexpected new value: .configuration_name: was
│ cty.StringVal("my-slack-channel-dev"), but now
│ cty.StringVal("my-slack-channel-de0415607ecdd122").
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 3 weeks ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue