terraform-provider-aws: [Bug]: Subsequent apply forces global cluster recreation when source cluster's database_name is specified

Terraform Core Version

0.12.31

AWS Provider Version

3.70.0

Affected Resource(s)

aws_rds_global_cluster

Expected Behavior

Subsequent apply should show no changes and no force replacement.

Actual Behavior

The subsequent apply shows a diff for the database_name parameter since this value is inherited from source cluster configuration and the applied configuration contains N/A value for this parameter.

-/+ resource "aws_rds_global_cluster" "this" {
      ~ arn                          = "************" -> (known after apply)
      - database_name                = "database04" -> null # forces replacement
        deletion_protection          = false
      ~ engine                       = "aurora" -> (known after apply)
      ~ engine_version               = "5.6.mysql_aurora.1.22.5" -> (known after apply)
        force_destroy                = true
        global_cluster_identifier    = "***************"
      ~ global_cluster_members       = [
          - {
              - db_cluster_arn = "******************"
              - is_writer      = true
            },
        ] -> (known after apply)
      ~ global_cluster_resource_id   = "**********" -> (known after apply)
      ~ id                           = "*************" -> (known after apply)
        source_db_cluster_identifier = "****************"
      ~ storage_encrypted            = true -> (known after apply)
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Relevant Error/Panic Output Snippet

Does not occur any error while terraform apply, but force replacement is occurred for database_name parameter
database_name                = "database04" -> null # forces replacement

Terraform Configuration Files


resource "aws_rds_cluster" "primary" {
    apply_immediately                   = true
    availability_zones                  = ["ap-south-1a", "ap-south-1b", "ap-south-1c"]
    backtrack_window                    = 0
    backup_retention_period             = 1
    cluster_identifier                  = "****************"
    copy_tags_to_snapshot               = true
    database_name                       = "database04"
    deletion_protection                 = false
    enable_http_endpoint                = false
    enabled_cloudwatch_logs_exports     = ["error", "slowquery"]
    engine_mode                         = "provisioned"
    engine_version                      = "5.6.mysql_aurora.1.22.5"
    engine                              = "aurora"
    final_snapshot_identifier           = "******************"
    iam_database_authentication_enabled = false
    master_password                     = "*******"
    master_username                     = "dbadmin"
    port                                = 5432
    preferred_backup_window             = "03:30-05:00"
    preferred_maintenance_window        = "sun:19:00-mon:00:00"
    skip_final_snapshot                 = true
    storage_encrypted                   = false



}



data "aws_rds_cluster" "clusterName" {
  cluster_identifier = "****************"

}




resource "aws_rds_global_cluster" "example" {
  source_db_cluster_identifier = data.aws_rds_cluster.clusterName.arn
    global_cluster_identifier = "******************"
    deletion_protection       = false
    force_destroy             = true
}

Steps to Reproduce

terraform apply terraform plan

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

This github issue is similar issue for ‘storage_encrypted’ parameter in this same resource. https://github.com/hashicorp/terraform-provider-aws/issues/15177

Would you like to implement a fix?

None

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 29
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Hi all,

I faced the same issue, I used this workarround, hope that could work also with you

resource "aws_rds_global_cluster" "example" {
  ...
  lifecycle {
    ignore_changes = [database_name]
  }
}