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_mq_broker only allows me to set engine version to 3.13 instead of 3.13.6 #38930

Closed borela closed 2 days ago

borela commented 3 weeks ago

Terraform Core Version

1.8.2-1

AWS Provider Version

5.63.0

Affected Resource(s)

aws_mq_broker

Expected Behavior

Allowed me to set engine version using the minor version too.

Actual Behavior

Keeps trying to set it to 3.13

# module.aws.module.rabbitmq_v3_13.aws_mq_broker.broker will be updated in-place
~ resource "aws_mq_broker" "broker" {
    ~ engine_version                = "3.13.6" -> "3.13"
      id                            = "b-e380aa62-9e30-4f2e-bac5-bffb1415307c"
      tags                          = {
          "App" = "Shared"
      }
      # (16 unchanged attributes hidden)

    ~ configuration {
        ~ id       = "c-5902d33e-0ef9-45d1-b5c2-abb62fa27812" -> "c-917a03fc-aaed-4f9c-9f5c-2e92e669376e"
          # (1 unchanged attribute hidden)
      }

      # (3 unchanged blocks hidden)
  }

But later, on the next apply, it notices AWS set it to 3.13.6

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply" which may have affected this plan:

  # module.aws.module.rabbitmq_v3_13.aws_mq_broker.broker has changed
  ~ resource "aws_mq_broker" "broker" {
      ~ engine_version                = "3.13" -> "3.13.6"
        id                            = "b-e380aa62-9e30-4f2e-bac5-bffb1415307c"
        tags                          = {
            "App" = "Shared"
        }
        # (16 unchanged attributes hidden)

      ~ configuration {
          ~ id       = "c-917a03fc-aaed-4f9c-9f5c-2e92e669376e" -> "c-5902d33e-0ef9-45d1-b5c2-abb62fa27812"
            # (1 unchanged attribute hidden)
        }

        # (3 unchanged blocks hidden)
    }

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

If I try to set to 3.13.6, it gives an error.

│ Error: creating MQ Configuration (staging-main-v3_13-configuration): operation error mq: CreateConfiguration, https response error StatusCode: 400, RequestID: 14095f86-a3c7-4185-9413-7bc6f95c873e, BadRequestException: Broker engine version [3.13.6] is invalid for broker engine type [RABBITMQ]. Valid values: [3.13, 3.12.13, 3.11.28, 3.11.20, 3.11.16, 3.10.25, 3.10.20, 3.10.10, 3.9.27].

Steps to Reproduce

Try to create any rabbitmq instance with the version 3.13.6

Debug Output

No response

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

ofiesh commented 3 weeks ago

The desired behavior for setting the minor version does not solve the problem.

With 3.13, automatic minor version upgrades are required (which is why we can't set the minor version). If terraform allows us to specify the minor version and that matches the latest, when a new minor version is released it will reintroduce the problem.

The expected behavior should be: When the automatic minor version upgrades are enabled and the major version matches, then terraform should not change the version.

borela commented 3 weeks ago

@ofiesh That makes sense; your proposed solution would solve the problem much better.

m-brgs commented 3 weeks ago

Exactly the same problem with ActiveMQ where AWS enforces "auto minor updates" since version 5.18 (i.e. patch upgrades in version number) but the server still returns the patch version number. This means that any auto-patch from AWS will create a diff in Terraform -- which is a no-go for us.

We expect to specify 5.18 without the patch value in the engine_version variable as auto minor version upgrades are enforced since this ActiveMQ version.

"BadRequestException: Brokers on [ActiveMQ] version [5.18] must have [autoMinorVersionUpgrade] set to [true]."

# The servers responds 5.18.4 after the upgrade.
# If we apply this, it triggers an update (i.e. reboot) of the cluster (which is not expected) but no version is changed (which is expected).
  ~ resource "aws_mq_broker" "activemq" {
      ~ engine_version             = "5.18.4" -> "5.18"

Note that the aws_mq_configuration does expects and returns 5.18 and will give an error if we try to specify the patch number when using version >= 5.18. This behavior seems appropriate.

resource "aws_mq_configuration" "broker" {
  engine_version = var.engine_version

We decided to tell Terraform to ignore changes until this issue is fixed.

  lifecycle {
    ignore_changes = [ engine_version ]
  }
justinretzolk commented 3 weeks ago

Similar #38708

architec commented 3 weeks ago

Hi, I can work on this issue

@justinretzolk

architec commented 3 weeks ago

The solution proposed by @ofiesh will additionally resolve issue #14705.

el-chazmo commented 3 weeks ago

I reached out to AWS regarding this. Response was: -

With the introduction of compulsory automatic minor version upgrades for 5.18, where the service will always default to the next compatible and secure patch version upon broker creation/update, it would be expected for MQ to only allow you to select version 5.18 given the dynamic nature of this approach.

github-actions[bot] commented 2 days ago

[!WARNING] This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.