Skip to content

Commit 387a98e

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 387a98e

1 file changed

Lines changed: 13 additions & 3 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

0 commit comments

Comments
 (0)