Skip to content

Commit 6cdb058

Browse files
committed
Enable replication from a specific snapshot
* Add optional input for the DB Snapshot Arn to the Github workflow
1 parent 866b6a0 commit 6cdb058

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
- Destroy
2828
- Recreate
2929
default: Recreate
30+
db_snapshot_arn:
31+
description: ARN of the DB snapshot to use (optional)
32+
required: false
33+
type: string
3034

3135
env:
3236
aws_role: ${{ inputs.environment == 'production'
@@ -58,9 +62,15 @@ jobs:
5862
id: get-latest-snapshot
5963
run: |
6064
set -e
61-
SNAPSHOT_ARN=$(aws rds describe-db-cluster-snapshots \
62-
--query 'DBClusterSnapshots[?contains(DBClusterSnapshotIdentifier, `${{ inputs.environment}}`)].[DBClusterSnapshotArn, SnapshotCreateTime]' \
63-
--output text | sort -k2 -r | head -n 1 | cut -f1)
65+
if [ -z "${{ inputs.db_snapshot_arn }}" ]; then
66+
echo "No snapshot ARN provided, fetching the latest snapshot"
67+
SNAPSHOT_ARN=$(aws rds describe-db-cluster-snapshots \
68+
--query 'DBClusterSnapshots[?contains(DBClusterSnapshotIdentifier, `${{ inputs.environment}}`)].[DBClusterSnapshotArn, SnapshotCreateTime]' \
69+
--output text | sort -k2 -r | head -n 1 | cut -f1)
70+
else
71+
echo "Using provided snapshot ARN: ${{ inputs.db_snapshot_arn }}"
72+
SNAPSHOT_ARN="${{ inputs.db_snapshot_arn }}"
73+
fi
6474
echo "SNAPSHOT_ARN=$SNAPSHOT_ARN" >> $GITHUB_OUTPUT
6575
- name: Install terraform
6676
uses: hashicorp/setup-terraform@v3
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
environment = "test"
22
rails_master_key_path = "/copilot/mavis/secrets/STAGING_RAILS_MASTER_KEY"
3-
db_engine_version = "16.8"

terraform/data_replication/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ variable "region" {
2020

2121
variable "db_engine_version" {
2222
type = string
23-
default = "14"
23+
default = "16.8"
2424
description = "The version of the database engine to use."
2525
nullable = false
2626
}

0 commit comments

Comments
 (0)