Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster is recreated with every apply #37

Closed
nodomain opened this issue Oct 22, 2018 · 5 comments
Closed

Cluster is recreated with every apply #37

nodomain opened this issue Oct 22, 2018 · 5 comments
Assignees

Comments

@nodomain
Copy link

This is linked to hashicorp/terraform#16724 and might be fixed by #35

Currently a terraform plan shows that the RDS cluster is recreated with every apply, the cause seems to be a wonky availability-zones attribute.
Somehow this seems to trigger a new resource. See plan output.

-/+ module.rds_cluster_aurora_mysql.aws_rds_cluster.default (new resource required)
      id:                                  "namespace-stage-project" => <computed> (forces new resource)
      apply_immediately:                   "true" => "true"
      arn:                                 "arn:aws:rds:eu-central-1:123456789:cluster:namespace-stage-project" => <computed>
      availability_zones.#:                "3" => "2" (forces new resource)
      availability_zones.1126047633:       "eu-central-1a" => "eu-central-1a"
      availability_zones.2903539389:       "eu-central-1c" => "" (forces new resource)
      availability_zones.3658960427:       "eu-central-1b" => "eu-central-1b"
      backup_retention_period:             "5" => "5"
      cluster_identifier:                  "namespace-stage-project" => "namespace-stage-project"
      cluster_identifier_prefix:           "" => <computed>
      cluster_members.#:                   "2" => <computed>
      cluster_resource_id:                 "cluster-AAAXXXX" => <computed>
      database_name:                       "project" => "project"
      db_cluster_parameter_group_name:     "namespace-stage-project" => "namespace-stage-project"
      db_subnet_group_name:                "namespace-stage-project" => "namespace-stage-project"
      endpoint:                            "namespace-stage-project.cluster-sensitive.eu-central-1.rds.amazonaws.com" => <computed>
      engine:                              "aurora-mysql" => "aurora-mysql"
      engine_mode:                         "provisioned" => "provisioned"
      engine_version:                      "5.7.12" => <computed>
      final_snapshot_identifier:           "namespace-stage-project" => "namespace-stage-project"
      hosted_zone_id:                      "Z1RLSENSITIVE" => <computed>
      iam_database_authentication_enabled: "false" => "false"
      kms_key_id:                          "arn:aws:kms:eu-central-1:123456789:key/xxx" => <computed>
      master_password:                     <sensitive> => <sensitive> (attribute changed)
      master_username:                     "project" => "project"
      port:                                "3306" => <computed>
      preferred_backup_window:             "07:00-09:00" => "07:00-09:00"
      preferred_maintenance_window:        "wed:03:00-wed:04:00" => "wed:03:00-wed:04:00"
      reader_endpoint:                     "namespace-stage-project.cluster-ro-sensitive.eu-central-1.rds.amazonaws.com" => <computed>
      skip_final_snapshot:                 "false" => "false"
      storage_encrypted:                   "true" => "true"
      tags.%:                              "3" => "3"
      tags.Name:                           "namespace-stage-project" => "namespace-stage-project"
      tags.Namespace:                      "namespace" => "namespace"
      tags.Stage:                          "stage" => "stage"
      vpc_security_group_ids.#:            "1" => "1"
      vpc_security_group_ids.636648702:    "sg-080d3cfa4609edea8" => "sg-080d3cfa4609edea8"

-/+ module.rds_cluster_aurora_mysql.aws_rds_cluster_instance.default[0] (new resource required)
      id:                                  "namespace-stage-project-1" => <computed> (forces new resource)
      apply_immediately:                   "" => <computed>
      arn:                                 "arn:aws:rds:eu-central-1:123456789:db:namespace-stage-project-1" => <computed>
      auto_minor_version_upgrade:          "true" => "true"
      availability_zone:                   "eu-central-1a" => <computed>
      cluster_identifier:                  "namespace-stage-project" => "${aws_rds_cluster.default.id}" (forces new resource)
      db_parameter_group_name:             "namespace-stage-project" => "namespace-stage-project"
      db_subnet_group_name:                "namespace-stage-project" => "namespace-stage-project"
      dbi_resource_id:                     "db-SENSITIVE0" => <computed>
      endpoint:                            "namespace-stage-project-1.sensitive.eu-central-1.rds.amazonaws.com" => <computed>
      engine:                              "aurora-mysql" => "aurora-mysql"
      engine_version:                      "5.7.12" => <computed>
      identifier:                          "namespace-stage-project-1" => "namespace-stage-project-1"
      identifier_prefix:                   "" => <computed>
      instance_class:                      "db.t2.small" => "db.t2.small"
      kms_key_id:                          "arn:aws:kms:eu-central-1:123456789:key/xxx" => <computed>
      monitoring_interval:                 "0" => "0"
      monitoring_role_arn:                 "" => <computed>
      performance_insights_enabled:        "false" => <computed>
      performance_insights_kms_key_id:     "" => <computed>
      port:                                "3306" => <computed>
      preferred_backup_window:             "07:00-09:00" => <computed>
      preferred_maintenance_window:        "mon:04:25-mon:04:55" => <computed>
      promotion_tier:                      "0" => "0"
      publicly_accessible:                 "false" => "false"
      storage_encrypted:                   "true" => <computed>
      tags.%:                              "3" => "3"
      tags.Name:                           "namespace-stage-project" => "namespace-stage-project"
      tags.Namespace:                      "namespace" => "namespace"
      tags.Stage:                          "stage" => "stage"
      writer:                              "false" => <computed>

-/+ module.rds_cluster_aurora_mysql.aws_rds_cluster_instance.default[1] (new resource required)
      id:                                  "namespace-stage-project-2" => <computed> (forces new resource)
      apply_immediately:                   "" => <computed>
      arn:                                 "arn:aws:rds:eu-central-1:123456789:db:namespace-stage-project-2" => <computed>
      auto_minor_version_upgrade:          "true" => "true"
      availability_zone:                   "eu-central-1b" => <computed>
      cluster_identifier:                  "namespace-stage-project" => "${aws_rds_cluster.default.id}" (forces new resource)
      db_parameter_group_name:             "namespace-stage-project" => "namespace-stage-project"
      db_subnet_group_name:                "namespace-stage-project" => "namespace-stage-project"
      dbi_resource_id:                     "db-SENSITIVE1" => <computed>
      endpoint:                            "namespace-stage-project-2.sensitive.eu-central-1.rds.amazonaws.com" => <computed>
      engine:                              "aurora-mysql" => "aurora-mysql"
      engine_version:                      "5.7.12" => <computed>
      identifier:                          "namespace-stage-project-2" => "namespace-stage-project-2"
      identifier_prefix:                   "" => <computed>
      instance_class:                      "db.t2.small" => "db.t2.small"
      kms_key_id:                          "arn:aws:kms:eu-central-1:123456789:key/xxx" => <computed>
      monitoring_interval:                 "0" => "0"
      monitoring_role_arn:                 "" => <computed>
      performance_insights_enabled:        "false" => <computed>
      performance_insights_kms_key_id:     "" => <computed>
      port:                                "3306" => <computed>
      preferred_backup_window:             "07:00-09:00" => <computed>
      preferred_maintenance_window:        "sun:03:45-sun:04:15" => <computed>
      promotion_tier:                      "0" => "0"
      publicly_accessible:                 "false" => "false"
      storage_encrypted:                   "true" => <computed>
      tags.%:                              "3" => "3"
      tags.Name:                           "namespace-stage-project" => "namespace-stage-project"
      tags.Namespace:                      "namespace" => "namespace"
      tags.Stage:                          "stage" => "stage"
      writer:                              "true" => <computed>

Config:

module "rds_cluster_aurora_mysql" {
  source             = "git::https://github.com/cloudposse/terraform-aws-rds-cluster.git?ref=master"
  engine             = "aurora-mysql"
  cluster_family     = "aurora-mysql5.7"
  cluster_size       = "${var.rds_cluster_size}"
  namespace          = "dc"
  stage              = "${element(split("-", var.name), 1)}"
  name               = "${element(split("-", var.name), 0)}"
  admin_user         = "${element(split("-", var.name), 0)}"
  admin_password     = "${random_string.password.result}"
  db_name            = "${element(split("-", var.name), 0)}"
  instance_type      = "${var.rds_instance_type}"
  vpc_id             = "${aws_vpc.this.id}"
  availability_zones = ["${var.azs}"]
  security_groups    = ["${module.security_group_webapp.this_security_group_id}", "${module.security_group_bastion.this_security_group_id}"]
  subnets            = ["${aws_subnet.private.*.id}"]
  # zone_id            = "${aws_route53_zone.internal.zone_id}"
  storage_encrypted  = true
  maintenance_window = "wed:03:00-wed:04:00"
  skip_final_snapshot = false
}

I assume that it would work fine with the availability_zones variable dropped.

@nodomain
Copy link
Author

See also hashicorp/terraform#16724 (comment)

@aknysh aknysh self-assigned this Oct 22, 2018
@aknysh
Copy link
Member

aknysh commented Oct 22, 2018

thanks @nodomain
we'll review it promptly

@thoellrich
Copy link

One more report on the very same issue as reported. And again it seems to be related to AZs in a different region this time. My config specifies 2a and 2b. us-east-2 has 3 AZs.

image

@aknysh
Copy link
Member

aknysh commented Oct 31, 2018

thanks @nodomain and @thoellrich
addressed in #38

@thoellrich
Copy link

Thanks for the fix! This appears to be corrected now in my environment. Appreciate the quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants