Terraform-provider-aws: Not recognizing global RDS DB Clusters with version 5.7.mysql_aurora.2.07.0+

Created on 25 Mar 2020  ·  4Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

0.12.24

Affected Resource(s)

aws_rds_cluster

Expected Behavior

When creating an RDS cluster with engine_mode = "global" (and with a global_cluster_identifier), the cluster should be created and added to the specified global RDS cluster. When running terraform apply again, there should be no changes found.

Actual Behavior

For Aurora MySQL version 5.7.mysql_aurora.2.07.0 and above, the DescribeDBClusters API endpoint returns engine_mode = "provisioned" for global clusters, instead of the expected engine_mode = "global". This causes Terraform to think that the engine mode has changed and that the cluster must be replaced when terraform apply is re-run. I confirmed this behaviour with AWS Support, and they said that this is intentional (and they will be updating the documentation to note this in the future).

They stated that the proper way to determine if a DB cluster is part of a global cluster is to call the DescribeGlobalClusters endpoint to see if the cluster in question is listed as a member of a global cluster.

This is a relatively easy fix: around this line, the provider needs to call the rdsDescribeGlobalClusterFromDbClusterARN function for all DB clusters, not just the ones with engine_mode = "global".

Steps to Reproduce

  1. Create a global DB cluster, as instructed in the documentation (but specifying engine version 5.7.mysql_aurora.2.07.0)
  2. Run terraform apply
  3. Run terraform apply again and note that it tries to replace the cluster.
bug servicrds upstream

Most helpful comment

We're running into this as well. The experience is that after a fresh creation of a global MySQL 5.7 RDS Aurora cluster and associated resources, a fresh plan returns these changes rather than being a no-op:

  • The primary aws_rds_cluster tries to add the global_cluster_identifier attribute:
~ resource "aws_rds_cluster" "primary" {
         arn                                 = "arn:aws:rds:us-east-1:0000000000:cluster:foo-us-east-1"
         ...
         cluster_identifier                  = "foo-us-east-1"
         cluster_resource_id                 = "cluster-foo"
         engine                              = "aurora-mysql"
         engine_mode                         = "provisioned"
         engine_version                      = "5.7.mysql_aurora.2.07.1"
       + global_cluster_identifier           = "foo"
         ...
     }
  • The secondary aws_rds_cluster tries to add the global_cluster_identifier attribute and unset the replication_source_identifier attribute:
~ resource "aws_rds_cluster" "secondary" {
         arn                                 = "arn:aws:rds:us-west-1:0000000000:cluster:foo-us-west-1"
         ...
         cluster_identifier                  = "foo-us-west-1"
         cluster_resource_id                 = "cluster-foo"
         engine                              = "aurora-mysql"
         engine_mode                         = "provisioned"
         engine_version                      = "5.7.mysql_aurora.2.07.1"
       + global_cluster_identifier           = "foo"
         ...
       - replication_source_identifier       = "arn:aws:rds:us-east-1:0000000000:cluster:foo-us-east-1" -> null
     }

An apply of these changes fails with:

 Error: Existing RDS Clusters cannot be added to an existing RDS Global Cluster

It seems RDS is responding with the correct fields, its just that the terraform provider isnt populating them due to the inaccurate logic mentioned above.

I agree with the proposal to update the logic for deciding whether to rdsDescribeGlobalClusterFromDbClusterARN

All 4 comments

We're running into this as well. The experience is that after a fresh creation of a global MySQL 5.7 RDS Aurora cluster and associated resources, a fresh plan returns these changes rather than being a no-op:

  • The primary aws_rds_cluster tries to add the global_cluster_identifier attribute:
~ resource "aws_rds_cluster" "primary" {
         arn                                 = "arn:aws:rds:us-east-1:0000000000:cluster:foo-us-east-1"
         ...
         cluster_identifier                  = "foo-us-east-1"
         cluster_resource_id                 = "cluster-foo"
         engine                              = "aurora-mysql"
         engine_mode                         = "provisioned"
         engine_version                      = "5.7.mysql_aurora.2.07.1"
       + global_cluster_identifier           = "foo"
         ...
     }
  • The secondary aws_rds_cluster tries to add the global_cluster_identifier attribute and unset the replication_source_identifier attribute:
~ resource "aws_rds_cluster" "secondary" {
         arn                                 = "arn:aws:rds:us-west-1:0000000000:cluster:foo-us-west-1"
         ...
         cluster_identifier                  = "foo-us-west-1"
         cluster_resource_id                 = "cluster-foo"
         engine                              = "aurora-mysql"
         engine_mode                         = "provisioned"
         engine_version                      = "5.7.mysql_aurora.2.07.1"
       + global_cluster_identifier           = "foo"
         ...
       - replication_source_identifier       = "arn:aws:rds:us-east-1:0000000000:cluster:foo-us-east-1" -> null
     }

An apply of these changes fails with:

 Error: Existing RDS Clusters cannot be added to an existing RDS Global Cluster

It seems RDS is responding with the correct fields, its just that the terraform provider isnt populating them due to the inaccurate logic mentioned above.

I agree with the proposal to update the logic for deciding whether to rdsDescribeGlobalClusterFromDbClusterARN

The fix for this has been merged and will release with version 2.59.0 of the Terraform AWS Provider, later today. 👍

This has been released in version 2.59.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings