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.87k stars 9.21k forks source link

Omit minor version in rds_cluster engine_version for aurora mysql #25348

Open multifunctional opened 2 years ago

multifunctional commented 2 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

Affected Resource(s)

Terraform Configuration Files

resource "aws_rds_cluster" "myclustername" {
  cluster_identifier = lower(local.prefix)
  engine             = "aurora-mysql"
  engine_version     = "5.7.mysql_aurora.2.07"
}

Expected Behavior

My aurora mysql cluster is originally set up with engine_version = "5.7.mysql_aurora.2.07.6". I want be able to omit the minor version for aurora mysql (using aws_rds_cluster), so that AWS can automatically upgrade the minor version when needed. Based on the document in https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster, I should be able to specify partial engine version. But this doesn't work, and is related to the issue described https://github.com/hashicorp/terraform-provider-aws/issues/13147 (where the issue is only resolved for db_instance, not rds_cluster nor rds_cluster_instance.

Actual Behavior

When I remove the minor version from the engine_version, i.e. changed from "5.7.mysql_aurora.2.07.6" to ""5.7.mysql_aurora.2.07", I get the error below in my terraform plan & deploy.

aws_rds_cluster.myclustername will be updated in-place
  ~ resource "aws_rds_cluster" "myclustername" {
      ~ engine_version                      = "5.7.mysql_aurora.2.07.6" -> "5.7.mysql_aurora.2.07"
        id                                  = "my-cluster-name"
        # (33 unchanged attributes hidden)
    }

Error: Failed to modify RDS Cluster (my-cluster-name): InvalidParameterCombination: Cannot find upgrade target from 5.7.mysql_aurora.2.07.6 with requested version 5.7.mysql_aurora.2.07.
gchamon commented 1 year ago

@multifunctional from what I understood, the omission is supported as long as the AWS API supports it. I believe in this case, AWS doesn't support this kind of omission in the engine_version parameter. I read the Aurora documentation but couldn't really find any reference to the patch version omission, neither saying it does nor doesn't offer this support.

phanitnum commented 1 year ago

@multifunctional did you try using "5.7.mysql_aurora" instead of "5.7.mysql_aurora.2.07" as the engine_version ?

gchamon commented 1 year ago

@phanitnum RDS API answers with InvalidParameterCombination: Cannot find upgrade target from 5.7.mysql_aurora.2.10.3 with requested version 5.7.mysql_aurora. status code: 400

robertkruk commented 1 year ago

I havent found a way around this except to bump to the latest correct version

cameronattard commented 1 year ago

It would be great to have this feature. It's really annoying to have hundreds of clusters in our fleet require manual Terraform code changes when AWS rolls out automatic minor version upgrades.

james-green-affinity commented 1 year ago

I use this method has worked for me.

Rather than doing this: "5.7.mysql_aurora.2.07.6" -> "5.7.mysql_aurora.2.07"

Do this instead: engine = "aurora-mysql" engine_version = "5.7" engine_mode = "provisioned"

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#engine_version https://stackoverflow.com/questions/66245653/aws-rds-database-version-is-different-than-terraform-version