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.8k stars 9.15k forks source link

[Bug]: AMQ Broker (Specifically RabbitMQ) Should Force a New Resource when Downgrading to `mq.t3.micro` #29495

Open korenyoni opened 1 year ago

korenyoni commented 1 year ago

Terraform Core Version

1.3.9

AWS Provider Version

4.55.0

Affected Resource(s)

Expected Behavior

When downgrading the instance type (host_instance_type) to mq.t3.micro in aws_mq_broker when engine_type is RabbitMQ, CustomizeDiff should force a new resource (probably via ForceNewIfChange).

https://github.com/hashicorp/terraform-provider-aws/blob/ae683662502d49e73caf3a8d01fb4689ab400592/internal/service/mq/broker.go#L335-L350

Downgrading hostInstanceType to mq.t3.micro is not allowed by the AMQ API.

https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/rmq-broker-instance-types.html

Actual Behavior

The Provider does not catch said condition, and the UpdateBroker request is sent to the AWS REST API, where it is rejected:

image

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_mq_broker" "example" {
  broker_name = "example"

  configuration {
    id       = aws_mq_configuration.test.id
    revision = aws_mq_configuration.test.latest_revision
  }

  engine_type        = "ActiveMQ"
  engine_version     = "5.15.9"
-  host_instance_type = "mq.m5.large"
+  host_instance_type = "mq.t3.micro"
  security_groups    = [aws_security_group.test.id]

  user {
    username = "ExampleUser"
    password = "MindTheGap"
  }
}

Steps to Reproduce

$ terraform init
$ terraform apply # before diff
$ terraform apply # after diff

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue