Skip to content

Commit

Permalink
feat(db): add support for checking cluster username
Browse files Browse the repository at this point in the history
  • Loading branch information
roleyfoley committed Feb 4, 2024
1 parent 2c4574f commit 39126c5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions execution/utility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 39126c5

Please sign in to comment.