Skip to content

Commit 97c19a4

Browse files
Merge pull request #4724 from nhsuk/data_replication_self_managed_password
Create independent password for data replication
2 parents 16c887b + 1c30ccd commit 97c19a4

5 files changed

Lines changed: 15 additions & 32 deletions

File tree

.github/workflows/refresh-data-replication.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ jobs:
146146
uses: hashicorp/setup-terraform@v3
147147
with:
148148
terraform_version: 1.13.3
149-
- name: Get db secret arn
150-
id: get-db-secret-arn
151-
working-directory: terraform/app
152-
run: |
153-
terraform init -backend-config="env/$environment-backend.hcl" -upgrade
154-
DB_SECRET_ARN=$(terraform output --raw db_secret_arn)
155-
echo "DB_SECRET_ARN=$DB_SECRET_ARN" >> $GITHUB_OUTPUT
156149
- name: Terraform Plan
157150
id: plan
158151
run: |
@@ -161,7 +154,6 @@ jobs:
161154
162155
PLAN_ARGS=(
163156
"plan"
164-
"-var=db_secret_arn=${{ steps.get-db-secret-arn.outputs.DB_SECRET_ARN }}"
165157
"-var=imported_snapshot=$SNAPSHOT_ARN"
166158
"-var-file=env/$environment.tfvars"
167159
"-var=allowed_egress_cidr_blocks=$egress_cidr"

terraform/app/outputs.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
output "db_secret_arn" {
2-
description = "The ARN of the secret containing the DB credentials."
3-
value = aws_rds_cluster.core.master_user_secret[0].secret_arn
4-
}

terraform/data_replication/iam.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ data "aws_iam_policy_document" "ecs_permissions" {
1111
sid = "dbSecretSid"
1212
actions = ["secretsmanager:GetSecretValue"]
1313
resources = [
14-
var.db_secret_arn
14+
aws_rds_cluster.cluster.master_user_secret[0].secret_arn
1515
]
1616
effect = "Allow"
1717
}

terraform/data_replication/rds.tf

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ resource "aws_security_group_rule" "rds_inbound" {
1717
}
1818

1919
resource "aws_rds_cluster" "cluster" {
20-
cluster_identifier = "${local.name_prefix}-rds-${formatdate("hh-mm-ss", timestamp())}"
21-
engine = "aurora-postgresql"
22-
engine_mode = "provisioned"
23-
database_name = "manage_vaccinations"
24-
master_username = "postgres"
25-
snapshot_identifier = var.imported_snapshot
26-
db_subnet_group_name = aws_db_subnet_group.dbsg.name
27-
vpc_security_group_ids = [aws_security_group.rds.id]
28-
storage_encrypted = true
29-
skip_final_snapshot = true
30-
deletion_protection = false
31-
engine_version = var.db_engine_version
20+
cluster_identifier = "${local.name_prefix}-rds-${formatdate("hh-mm-ss", timestamp())}"
21+
engine = "aurora-postgresql"
22+
engine_mode = "provisioned"
23+
database_name = "manage_vaccinations"
24+
master_username = "postgres"
25+
snapshot_identifier = var.imported_snapshot
26+
db_subnet_group_name = aws_db_subnet_group.dbsg.name
27+
vpc_security_group_ids = [aws_security_group.rds.id]
28+
storage_encrypted = true
29+
skip_final_snapshot = true
30+
deletion_protection = false
31+
manage_master_user_password = true
32+
engine_version = var.db_engine_version
3233

3334
serverlessv2_scaling_configuration {
3435
max_capacity = var.max_aurora_capacity_units

terraform/data_replication/variables.tf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ variable "max_aurora_capacity_units" {
3737
description = "Maximum amount of allowed ACU capacity for Aurora Serverless v2"
3838
}
3939

40-
variable "db_secret_arn" {
41-
type = string
42-
description = "The ARN of the secret that stores the credentials for the database from which the snapshot originates."
43-
nullable = false
44-
}
45-
4640
variable "account_id" {
4741
type = string
4842
default = "393416225559"
@@ -83,7 +77,7 @@ locals {
8377
task_secrets = [
8478
{
8579
name = "DB_CREDENTIALS"
86-
valueFrom = var.db_secret_arn
80+
valueFrom = aws_rds_cluster.cluster.master_user_secret[0].secret_arn
8781
},
8882
{
8983
name = "RAILS_MASTER_KEY"

0 commit comments

Comments
 (0)