mdn / infra

(Deprecated) MDN Web Docs Infrastructure scripts and configuration
Mozilla Public License 2.0
53 stars 32 forks source link

SE-2280 Decom mysql #508

Closed bkochendorfer closed 3 years ago

bkochendorfer commented 3 years ago

We are moving away from Mysql to Postgres. We have backups of the mysql databases and they can now be decommed.

  # module.mysql-eu-central-1-replica-prod.aws_db_instance.replica[0] will be destroyed
  - resource "aws_db_instance" "replica" {
      - address                               = "mdn-prod-replica.cdnr0ilttchi.eu-central-1.rds.amazonaws.com" -> null
      - allocated_storage                     = 200 -> null
      - apply_immediately                     = true -> null
      - arn                                   = "arn:aws:rds:eu-central-1:178589013767:db:mdn-prod-replica" -> null
      - auto_minor_version_upgrade            = true -> null
      - availability_zone                     = "eu-central-1b" -> null
      - backup_retention_period               = 0 -> null
      - backup_window                         = "00:00-00:30" -> null
      - ca_cert_identifier                    = "rds-ca-2019" -> null
      - copy_tags_to_snapshot                 = false -> null
      - db_subnet_group_name                  = "mdn-prod-replica-subnet-group" -> null
      - delete_automated_backups              = true -> null
      - deletion_protection                   = false -> null
      - enabled_cloudwatch_logs_exports       = [] -> null
      - endpoint                              = "mdn-prod-replica.cdnr0ilttchi.eu-central-1.rds.amazonaws.com:3306" -> null
      - engine                                = "mysql" -> null
      - engine_version                        = "5.6.51" -> null
      - hosted_zone_id                        = "Z1RLNUO7B9Q6NB" -> null
      - iam_database_authentication_enabled   = false -> null
      - id                                    = "mdn-prod-replica" -> null
      - identifier                            = "mdn-prod-replica" -> null
      - instance_class                        = "db.m5.xlarge" -> null
      - iops                                  = 0 -> null
      - kms_key_id                            = "arn:aws:kms:eu-central-1:178589013767:key/d825fec7-2f43-4010-b91f-782876263bb8" -> null
      - latest_restorable_time                = "0001-01-01T00:00:00Z" -> null
      - license_model                         = "general-public-license" -> null
      - maintenance_window                    = "sun:00:31-sun:01:01" -> null
      - max_allocated_storage                 = 0 -> null
      - monitoring_interval                   = 60 -> null
      - monitoring_role_arn                   = "arn:aws:iam::178589013767:role/rds-monitoring-role" -> null
      - multi_az                              = true -> null
      - name                                  = "developer_mozilla_org" -> null
      - option_group_name                     = "default:mysql-5-6" -> null
      - parameter_group_name                  = "default.mysql5.6" -> null
      - performance_insights_enabled          = false -> null
      - performance_insights_retention_period = 0 -> null
      - port                                  = 3306 -> null
      - publicly_accessible                   = false -> null
      - replicas                              = [] -> null
      - replicate_source_db                   = "arn:aws:rds:us-west-2:178589013767:db:mdn-prod" -> null
      - resource_id                           = "db-A6YOMVWAT4XH5GSDMF3CXBFV4A" -> null
      - security_group_names                  = [] -> null
      - skip_final_snapshot                   = true -> null
      - status                                = "available" -> null
      - storage_encrypted                     = true -> null
      - storage_type                          = "gp2" -> null
      - tags                                  = {
          - "Environment" = "prod"
          - "Name"        = "mdn-prod-replica"
          - "Region"      = "eu-central-1"
          - "Service"     = "MDN"
          - "Terraform"   = "true"
        } -> null
      - tags_all                              = {
          - "Environment" = "prod"
          - "Name"        = "mdn-prod-replica"
          - "Region"      = "eu-central-1"
          - "Service"     = "MDN"
          - "Terraform"   = "true"
        } -> null
      - username                              = "root" -> null
      - vpc_security_group_ids                = [
          - "sg-0a3c4a1e571399d66",
        ] -> null

      - timeouts {}
    }

  # module.mysql-eu-central-1-replica-prod.aws_security_group.replica-sg[0] will be updated in-place
  ~ resource "aws_security_group" "replica-sg" {
        id                     = "sg-0a3c4a1e571399d66"
      ~ ingress                = [
          - {
              - cidr_blocks      = [
                  - "172.20.0.0/16",
                ]
              - description      = ""
              - from_port        = 3306
              - ipv6_cidr_blocks = []
              - prefix_list_ids  = []
              - protocol         = "TCP"
              - security_groups  = []
              - self             = false
              - to_port          = 3306
            },
          - {
              - cidr_blocks      = [
                  - "172.20.0.0/16",
                ]
              - description      = ""
              - from_port        = 5432
              - ipv6_cidr_blocks = []
              - prefix_list_ids  = []
              - protocol         = "tcp"
              - security_groups  = []
              - self             = false
              - to_port          = 5432
            },
          + {
              + cidr_blocks      = [
                  + "172.20.0.0/16",
                ]
              + description      = null
              + from_port        = 5432
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = []
              + self             = false
              + to_port          = 5432
            },
        ]
        name                   = "mdn-prod-replica-sg"
        tags                   = {
            "Environment" = "prod"
            "Name"        = "mdn-prod-replica-sg"
            "Region"      = "eu-central-1"
            "Service"     = "MDN"
            "Terraform"   = "true"
        }
        # (7 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

  # module.mysql-us-west-2.aws_db_instance.mdn_rds[0] will be destroyed
  - resource "aws_db_instance" "mdn_rds" {
      - address                               = "mdn-stage.cvd5ntsxtv8p.us-west-2.rds.amazonaws.com" -> null
      - allocated_storage                     = 100 -> null
      - allow_major_version_upgrade           = false -> null
      - apply_immediately                     = true -> null
      - arn                                   = "arn:aws:rds:us-west-2:178589013767:db:mdn-stage" -> null
      - auto_minor_version_upgrade            = true -> null
      - availability_zone                     = "us-west-2c" -> null
      - backup_retention_period               = 1 -> null
      - backup_window                         = "00:00-00:30" -> null
      - ca_cert_identifier                    = "rds-ca-2019" -> null
      - copy_tags_to_snapshot                 = false -> null
      - db_subnet_group_name                  = "mdn-stage-rds-subnet-group" -> null
      - delete_automated_backups              = true -> null
      - deletion_protection                   = false -> null
      - enabled_cloudwatch_logs_exports       = [] -> null
      - endpoint                              = "mdn-stage.cvd5ntsxtv8p.us-west-2.rds.amazonaws.com:3306" -> null
      - engine                                = "mysql" -> null
      - engine_version                        = "5.6.51" -> null
      - hosted_zone_id                        = "Z1PVIF0B656C1W" -> null
      - iam_database_authentication_enabled   = false -> null
      - id                                    = "mdn-stage" -> null
      - identifier                            = "mdn-stage" -> null
      - instance_class                        = "db.t3.large" -> null
      - iops                                  = 0 -> null
      - kms_key_id                            = "arn:aws:kms:us-west-2:178589013767:key/e82d0945-5e72-4917-9e28-881304555fea" -> null
      - latest_restorable_time                = "2021-08-09T19:50:00Z" -> null
      - license_model                         = "general-public-license" -> null
      - maintenance_window                    = "sun:00:31-sun:01:01" -> null
      - max_allocated_storage                 = 0 -> null
      - monitoring_interval                   = 60 -> null
      - monitoring_role_arn                   = "arn:aws:iam::178589013767:role/rds-monitoring-role" -> null
      - multi_az                              = true -> null
      - name                                  = "developer_allizom_org" -> null
      - option_group_name                     = "default:mysql-5-6" -> null
      - parameter_group_name                  = "mdn-stage-params" -> null
      - password                              = (sensitive value)
      - performance_insights_enabled          = true -> null
      - performance_insights_kms_key_id       = "arn:aws:kms:us-west-2:178589013767:key/e82d0945-5e72-4917-9e28-881304555fea" -> null
      - performance_insights_retention_period = 0 -> null
      - port                                  = 3306 -> null
      - publicly_accessible                   = false -> null
      - replicas                              = [] -> null
      - resource_id                           = "db-W4J2P5M452VWI2IZS7FVD2YZ2Q" -> null
      - security_group_names                  = [] -> null
      - skip_final_snapshot                   = true -> null
      - status                                = "stopped" -> null
      - storage_encrypted                     = true -> null
      - storage_type                          = "gp2" -> null
      - tags                                  = {
          - "Environment" = "stage"
          - "Name"        = "MDN-rds-stage"
          - "Region"      = "us-west-2"
          - "Service"     = "MDN"
          - "Terraform"   = "true"
        } -> null
      - tags_all                              = {
          - "Environment" = "stage"
          - "Name"        = "MDN-rds-stage"
          - "Region"      = "us-west-2"
          - "Service"     = "MDN"
          - "Terraform"   = "true"
        } -> null
      - username                              = "root" -> null
      - vpc_security_group_ids                = [
          - "sg-e5ce2496",
        ] -> null

      - timeouts {}
    }

  # module.mysql-us-west-2.aws_db_parameter_group.mdn-params[0] will be destroyed
  - resource "aws_db_parameter_group" "mdn-params" {
      - arn         = "arn:aws:rds:us-west-2:178589013767:pg:mdn-stage-params" -> null
      - description = "Paramter group for mdn-stage" -> null
      - family      = "mysql5.6" -> null
      - id          = "mdn-stage-params" -> null
      - name        = "mdn-stage-params" -> null
      - tags        = {} -> null
      - tags_all    = {} -> null

      - parameter {
          - apply_method = "immediate" -> null
          - name         = "max_allowed_packet" -> null
          - value        = "26214400" -> null
        }
    }

  # module.mysql-us-west-2.aws_security_group.mdn_rds_sg[0] will be updated in-place
  ~ resource "aws_security_group" "mdn_rds_sg" {
        id                     = "sg-e5ce2496"
      ~ ingress                = [
          - {
              - cidr_blocks      = [
                  - "172.20.0.0/16",
                ]
              - description      = ""
              - from_port        = 3306
              - ipv6_cidr_blocks = []
              - prefix_list_ids  = []
              - protocol         = "TCP"
              - security_groups  = []
              - self             = false
              - to_port          = 3306
            },
          - {
              - cidr_blocks      = [
                  - "172.20.0.0/16",
                ]
              - description      = ""
              - from_port        = 5432
              - ipv6_cidr_blocks = []
              - prefix_list_ids  = []
              - protocol         = "tcp"
              - security_groups  = []
              - self             = false
              - to_port          = 5432
            },
          + {
              + cidr_blocks      = [
                  + "172.20.0.0/16",
                ]
              + description      = null
              + from_port        = 5432
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = []
              + self             = false
              + to_port          = 5432
            },
        ]
        name                   = "mdn_rds_sg_stage"
        tags                   = {
            "Environment" = "stage"
            "Name"        = "mdn_rds_sg-stage"
            "Region"      = "us-west-2"
            "Service"     = "MDN"
            "Terraform"   = "true"
        }
        # (7 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

  # module.mysql-us-west-2-prod.aws_db_instance.mdn_rds[0] will be destroyed
  - resource "aws_db_instance" "mdn_rds" {
      - address                               = "mdn-prod.cvd5ntsxtv8p.us-west-2.rds.amazonaws.com" -> null
      - allocated_storage                     = 200 -> null
      - allow_major_version_upgrade           = false -> null
      - apply_immediately                     = true -> null
      - arn                                   = "arn:aws:rds:us-west-2:178589013767:db:mdn-prod" -> null
      - auto_minor_version_upgrade            = true -> null
      - availability_zone                     = "us-west-2a" -> null
      - backup_retention_period               = 7 -> null
      - backup_window                         = "00:00-00:30" -> null
      - ca_cert_identifier                    = "rds-ca-2019" -> null
      - copy_tags_to_snapshot                 = false -> null
      - db_subnet_group_name                  = "mdn-prod-rds-subnet-group" -> null
      - delete_automated_backups              = true -> null
      - deletion_protection                   = false -> null
      - enabled_cloudwatch_logs_exports       = [] -> null
      - endpoint                              = "mdn-prod.cvd5ntsxtv8p.us-west-2.rds.amazonaws.com:3306" -> null
      - engine                                = "mysql" -> null
      - engine_version                        = "5.6.51" -> null
      - hosted_zone_id                        = "Z1PVIF0B656C1W" -> null
      - iam_database_authentication_enabled   = false -> null
      - id                                    = "mdn-prod" -> null
      - identifier                            = "mdn-prod" -> null
      - instance_class                        = "db.m5.xlarge" -> null
      - iops                                  = 0 -> null
      - kms_key_id                            = "arn:aws:kms:us-west-2:178589013767:key/e82d0945-5e72-4917-9e28-881304555fea" -> null
      - latest_restorable_time                = "2021-08-10T19:45:00Z" -> null
      - license_model                         = "general-public-license" -> null
      - maintenance_window                    = "sun:00:31-sun:01:01" -> null
      - max_allocated_storage                 = 0 -> null
      - monitoring_interval                   = 60 -> null
      - monitoring_role_arn                   = "arn:aws:iam::178589013767:role/rds-monitoring-role" -> null
      - multi_az                              = true -> null
      - name                                  = "developer_mozilla_org" -> null
      - option_group_name                     = "default:mysql-5-6" -> null
      - parameter_group_name                  = "mdn-prod-params" -> null
      - password                              = (sensitive value)
      - performance_insights_enabled          = true -> null
      - performance_insights_kms_key_id       = "arn:aws:kms:us-west-2:178589013767:key/e82d0945-5e72-4917-9e28-881304555fea" -> null
      - performance_insights_retention_period = 0 -> null
      - port                                  = 3306 -> null
      - publicly_accessible                   = false -> null
      - replicas                              = [
          - "mdn-prod-replica",
          - "arn:aws:rds:eu-central-1:178589013767:db:mdn-prod-replica",
        ] -> null
      - resource_id                           = "db-65GMQ6N3JMIWWHSHHWQDB6J4YU" -> null
      - security_group_names                  = [] -> null
      - skip_final_snapshot                   = true -> null
      - status                                = "available" -> null
      - storage_encrypted                     = true -> null
      - storage_type                          = "gp2" -> null
      - tags                                  = {
          - "Environment" = "prod"
          - "Name"        = "MDN-rds-prod"
          - "Region"      = "us-west-2"
          - "Service"     = "MDN"
          - "Terraform"   = "true"
        } -> null
      - tags_all                              = {
          - "Environment" = "prod"
          - "Name"        = "MDN-rds-prod"
          - "Region"      = "us-west-2"
          - "Service"     = "MDN"
          - "Terraform"   = "true"
        } -> null
      - username                              = "root" -> null
      - vpc_security_group_ids                = [
          - "sg-05582650bc1475423",
        ] -> null

      - timeouts {}
    }

  # module.mysql-us-west-2-prod.aws_db_parameter_group.mdn-params[0] will be destroyed
  - resource "aws_db_parameter_group" "mdn-params" {
      - arn         = "arn:aws:rds:us-west-2:178589013767:pg:mdn-prod-params" -> null
      - description = "Paramter group for mdn-prod" -> null
      - family      = "mysql5.6" -> null
      - id          = "mdn-prod-params" -> null
      - name        = "mdn-prod-params" -> null
      - tags        = {} -> null
      - tags_all    = {} -> null

      - parameter {
          - apply_method = "immediate" -> null
          - name         = "max_allowed_packet" -> null
          - value        = "26214400" -> null
        }
    }

  # module.mysql-us-west-2-prod.aws_security_group.mdn_rds_sg[0] will be updated in-place
  ~ resource "aws_security_group" "mdn_rds_sg" {
        id                     = "sg-05582650bc1475423"
      ~ ingress                = [
          - {
              - cidr_blocks      = [
                  - "172.20.0.0/16",
                ]
              - description      = ""
              - from_port        = 3306
              - ipv6_cidr_blocks = []
              - prefix_list_ids  = []
              - protocol         = "TCP"
              - security_groups  = []
              - self             = false
              - to_port          = 3306
            },
          - {
              - cidr_blocks      = [
                  - "172.20.0.0/16",
                ]
              - description      = ""
              - from_port        = 5432
              - ipv6_cidr_blocks = []
              - prefix_list_ids  = []
              - protocol         = "tcp"
              - security_groups  = []
              - self             = false
              - to_port          = 5432
            },
          + {
              + cidr_blocks      = [
                  + "172.20.0.0/16",
                ]
              + description      = null
              + from_port        = 5432
              + ipv6_cidr_blocks = []
              + prefix_list_ids  = []
              + protocol         = "tcp"
              + security_groups  = []
              + self             = false
              + to_port          = 5432
            },
        ]
        name                   = "mdn_rds_sg_prod"
        tags                   = {
            "Environment" = "prod"
            "Name"        = "mdn_rds_sg-prod"
            "Region"      = "us-west-2"
            "Service"     = "MDN"
            "Terraform"   = "true"
        }
        # (7 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 3 to change, 5 to destroy.

Changes to Outputs:
  + us-west-2-postgres-rds-endpoint = "mdn-stage-postgres.cvd5ntsxtv8p.us-west-2.rds.amazonaws.com:5432"
  - us-west-2-rds-endpoint          = "mdn-stage.cvd5ntsxtv8p.us-west-2.rds.amazonaws.com:3306" -> null

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
bkochendorfer commented 3 years ago

@escattone I do not think the replica will be destroyed automatically. In this plan it is being destroyed because we've removed it from the module definition for the replica. We'll see how Terraform and AWS handle this in reality when I run the delete.