Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(db): add support for checking cluster username #373

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading