From 8278eb0fc2c853701cc3cfb7ee7e68b2d9eeaff0 Mon Sep 17 00:00:00 2001 From: Michael Foley Date: Mon, 5 Feb 2024 10:06:09 +1100 Subject: [PATCH] feat(db): add support for checking cluster username (#373) --- execution/utility.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/execution/utility.sh b/execution/utility.sh index 9bbcaa93..f6114e4e 100755 --- a/execution/utility.sh +++ b/execution/utility.sh @@ -2476,15 +2476,19 @@ function get_rds_hostname() { function check_rds_snapshot_username() { local region="$1"; shift + local db_type="$1"; shift local db_snapshot_identifier="$1"; shift local expected_username="$1"; shift info "Checking snapshot username matches expected username" - snapshot_info="$(aws --region ${region} rds describe-db-snapshots --include-shared --include-public --db-snapshot-identifier ${db_snapshot_identifier} || return $? )" + if [[ "${db_type}" == "cluster" ]]; then + snapshot_username="$( aws --region ${region} rds describe-db-cluster-snapshots --include-shared --include-public --db-cluster-snapshot-identifier --output text --query 'DBClusterSnapshots[0].MasterUsername || ``' || return $? )" + else + snapshot_username="$(aws --region ${region} rds describe-db-snapshots --include-shared --include-public --db-snapshot-identifier ${db_snapshot_identifier} --output text --query 'DBSnapshots[0].MasterUsername || ``' || return $? )" + fi if [[ -n "${snapshot_info}" ]]; then - snapshot_username="$( echo "${snapshot_info}" | jq -r '.DBSnapshots[0].MasterUsername' )" if [[ "${snapshot_username}" != "${expected_username}" ]]; then