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.85k stars 9.2k forks source link

[Bug]: aurora global cluster keep recreating if new global cluster from existing primary cluster which has database_name #39368

Open wangyi198682 opened 2 months ago

wangyi198682 commented 2 months ago

Terraform Core Version

Terraform v1.9.0

AWS Provider Version

5.45.0

Affected Resource(s)

No response

Expected Behavior

no drift or no diffs when terraform plan again.

Actual Behavior

after second round run terraform plan or apply, we saw that it tries to recreate global cluster.

- database_name                = "mydb" -> null # forces replacement

and it recreates global cluster, this will cause global cluster's members being removed.

aws_rds_global_cluster.this[0]: Destroying... [id=example]
aws_rds_global_cluster.this[0]: Destruction complete after 3s
aws_rds_global_cluster.this[0]: Creating...
aws_rds_global_cluster.this[0]: Creation complete after 0s [id=example]

Apply complete! Resources: 1 added, 0 changed, 1 destroyed.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_rds_cluster" "primary" {
  //other configurations
  database_name   = "mydb"
  lifecycle {
    ignore_changes = [global_cluster_identifier]
  }
}

resource "aws_rds_global_cluster" "example" {
  force_destroy                = true
  global_cluster_identifier    = "example"
  source_db_cluster_identifier = aws_rds_cluster.primary.arn
}

Steps to Reproduce

step1: terraform plan & apply. step2: after all the resources created, then run terraform plan again.

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 2 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

wangyi198682 commented 2 months ago

and I solve it by using following change to "aws_rds_global_cluster"

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

Similar #28187