From 976968d4c9f4516eef9f3acde6fff4fc0f8a4c28 Mon Sep 17 00:00:00 2001 From: Alistair Curtis Date: Fri, 19 Jan 2024 17:08:23 +0000 Subject: [PATCH 1/2] restore rds from snapshot --- terraform/environments/cdpt-chaps/database.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/environments/cdpt-chaps/database.tf b/terraform/environments/cdpt-chaps/database.tf index 653ad0090ea..776ae785aba 100644 --- a/terraform/environments/cdpt-chaps/database.tf +++ b/terraform/environments/cdpt-chaps/database.tf @@ -9,11 +9,11 @@ resource "aws_db_instance" "database" { engine_version = "14.00.3381.3.v1" instance_class = local.application_data.accounts[local.environment].db_instance_class identifier = local.application_data.accounts[local.environment].db_instance_identifier - # username = local.application_data.accounts[local.environment].db_user + username = local.application_data.accounts[local.environment].db_user password = aws_secretsmanager_secret_version.db_password.secret_string vpc_security_group_ids = [aws_security_group.db.id] depends_on = [aws_security_group.db] - # snapshot_identifier = "arn:aws:rds:eu-west-2:613903586696:snapshot:chaps-prod-snapshot-2024-01-19" + snapshot_identifier = "arn:aws:rds:eu-west-2:613903586696:snapshot:chaps-prod-snapshot-2024-01-19" db_subnet_group_name = aws_db_subnet_group.db.id final_snapshot_identifier = "final-snapshot" publicly_accessible = true From 5b40692126b8da5ed471f68b4e12194710ce0083 Mon Sep 17 00:00:00 2001 From: Alistair Curtis Date: Mon, 22 Jan 2024 09:13:14 +0000 Subject: [PATCH 2/2] parameterised snapshots --- .../environments/cdpt-chaps/application_variables.json | 3 +++ terraform/environments/cdpt-chaps/database.tf | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/terraform/environments/cdpt-chaps/application_variables.json b/terraform/environments/cdpt-chaps/application_variables.json index 7ba86bac2b5..040992cf89d 100644 --- a/terraform/environments/cdpt-chaps/application_variables.json +++ b/terraform/environments/cdpt-chaps/application_variables.json @@ -7,6 +7,7 @@ "db_name": "chaps-dev", "env_name": "DEVELOPMENT", "db_instance_identifier": "db-chaps-dev", + "db_snapshot_identifier": "arn:aws:rds:eu-west-2:613903586696:snapshot:cdpt-dev-staging-snapshot-9-1-24", "docker_image_tag": "development", "app_count": 1, "ec2_desired_capacity": 1, @@ -25,6 +26,7 @@ "db_name": "chaps-staging", "env_name": "STAGING", "db_instance_identifier": "chaps-preprod-instance", + "db_snapshot_identifier": "arn:aws:rds:eu-west-2:613903586696:snapshot:cdpt-dev-staging-snapshot-9-1-24", "docker_image_tag": "preproduction", "app_count": 2, "ec2_desired_capacity": 2, @@ -43,6 +45,7 @@ "db_name": "chaps-prod", "env_name": "PRODUCTION", "db_instance_identifier": "chaps-prod-instance", + "db_snapshot_identifier": "arn:aws:rds:eu-west-2:613903586696:snapshot:chaps-prod-snapshot-2024-01-19", "docker_image_tag": "production", "app_count": 2, "ec2_desired_capacity": 2, diff --git a/terraform/environments/cdpt-chaps/database.tf b/terraform/environments/cdpt-chaps/database.tf index 776ae785aba..b039fd13c30 100644 --- a/terraform/environments/cdpt-chaps/database.tf +++ b/terraform/environments/cdpt-chaps/database.tf @@ -13,7 +13,7 @@ resource "aws_db_instance" "database" { password = aws_secretsmanager_secret_version.db_password.secret_string vpc_security_group_ids = [aws_security_group.db.id] depends_on = [aws_security_group.db] - snapshot_identifier = "arn:aws:rds:eu-west-2:613903586696:snapshot:chaps-prod-snapshot-2024-01-19" + snapshot_identifier = local.application_data.accounts[local.environment].db_snapshot_identifier db_subnet_group_name = aws_db_subnet_group.db.id final_snapshot_identifier = "final-snapshot" publicly_accessible = true @@ -25,10 +25,6 @@ resource "aws_db_instance_role_association" "database" { role_arn = aws_iam_role.S3_db_backup_restore_access.arn } -output "s3_db_backup_restore_access_role_arn" { - value = aws_iam_role.S3_db_backup_restore_access.arn -} - resource "aws_db_subnet_group" "db" { name = "${local.application_name}-db-subnet-group" subnet_ids = sort(data.aws_subnets.shared-data.ids)