terraform-aws-modules / terraform-aws-rds-aurora

Terraform module to create AWS RDS Aurora resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/rds-aurora/aws
Apache License 2.0
385 stars 573 forks source link

Cluster members are not ignored #419

Closed tetienne closed 9 months ago

tetienne commented 11 months ago

Description

When using autoscaling, the cluster members is modified outside Terraform, resulting in a plan with this message:

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.main_rds_cluster.aws_rds_cluster.this[0] has changed
  ~ resource "aws_rds_cluster" "this" {
      ~ cluster_members                     = [
          + "application-autoscaling-7c66e466-19ee-4cfe-8329-9d663c6b1a02",
            # (3 unchanged elements hidden)
        ]
        id                                  = "prod-rr-a-1-cluster"
        tags                                = {}
        # (37 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the
relevant attributes using ignore_changes, the following plan may include
actions to undo or respond to these changes.

I would like to ignore such changes.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

Reproduction Code [Required]

module "main_rds_cluster" {
  source  = "terraform-aws-modules/rds-aurora/aws"
  version = "8.5.0"

  name                         = "prod-rr-a-1-cluster"
  engine                       = "aurora-mysql"
  engine_version               = "8.0.mysql_aurora.3.05.1"
  backup_retention_period      = 2
  ca_cert_identifier           = "rds-ca-ecc384-g1"
  copy_tags_to_snapshot        = true
  master_username              = "mysqladmin"
  manage_master_user_password  = false
  preferred_backup_window      = "02:30-03:00"
  preferred_maintenance_window = "wed:01:00-wed:01:30"
  storage_encrypted            = false
  enabled_cloudwatch_logs_exports = [
    "audit",
    "error",
    "slowquery",
  ]
  skip_final_snapshot   = true
  deletion_protection   = true
  db_subnet_group_name  = "default"
  create_security_group = false
  vpc_security_group_ids = [ # TODO create dedicated security group from scratch
    "sg-8517e1e2",
  ]
  instance_class         = "db.r5.2xlarge"
  monitoring_interval    = 60
  create_monitoring_role = false
  monitoring_role_arn    = data.aws_iam_role.rds_monitoring.arn

  performance_insights_enabled    = true
  performance_insights_kms_key_id = data.aws_kms_key.rds.arn

  instances = {
    one = {
      identifier                   = "prod-rr-a-1"
      promotion_tier               = 1
    }
    two = {
      identifier                   = "prod-rr-a-2"
      promotion_tier               = 2
    }
    three = {
      identifier                   = "prod-rr-a-3"
      promotion_tier               = 3
    }

  }

  autoscaling_enabled            = true
  autoscaling_min_capacity       = 2
  autoscaling_max_capacity       = 8
  autoscaling_policy_name        = "ApplicationAutoScalingCPU"
  autoscaling_scale_in_cooldown  = 900
  autoscaling_scale_out_cooldown = 1800
  autoscaling_target_cpu         = 65

  create_db_cluster_parameter_group          = true
  db_cluster_parameter_group_name            = "aurora-mysql8-prod"
  db_cluster_parameter_group_description     = "aurora-mysql8-prod"
  db_cluster_parameter_group_family          = "aurora-mysql8.0"
  db_cluster_parameter_group_use_name_prefix = false
}

Expected behavior

No drift on the cluster_members attribute.

Actual behavior

Drift due to the auto scaling.

Terminal Output Screenshot(s)

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.main_rds_cluster.aws_rds_cluster.this[0] has changed
  ~ resource "aws_rds_cluster" "this" {
      ~ cluster_members                     = [
          + "application-autoscaling-7c66e466-19ee-4cfe-8329-9d663c6b1a02",
            # (3 unchanged elements hidden)
        ]
        id                                  = "prod-rr-a-1-cluster"
        tags                                = {}
        # (37 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the
relevant attributes using ignore_changes, the following plan may include
actions to undo or respond to these changes.

Additional context

github-actions[bot] commented 10 months ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

tetienne commented 10 months ago

Still valid.

tetienne commented 10 months ago

.

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 9 months ago

This issue was automatically closed because of stale in 10 days

github-actions[bot] commented 8 months ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.