Created
May 28, 2019 17:03
-
-
Save yeukhon/b3f0e651e07997d0671e44f95f436679 to your computer and use it in GitHub Desktop.
Revisions
-
yeukhon renamed this gist
May 28, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
yeukhon created this gist
May 28, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #!/bin/bash # This script takes two arguments: rds database identifier and timeout. DB_ID=$1 TIMEOUT=$2 POLL_INTERVAL=60 OK_STATES=("backing-up" "available" "modifying" "resetting-master-credentials") seconds_left=$TIMEOUT while [[ "${seconds_left}" -gt 0 ]] do db_status=$(aws rds describe-db-instances --db-instance-identifier $DB_ID --query 'DBInstances[0].[DBInstanceStatus]' --output text) if [[ "${OK_STATES[@]} " =~ "${db_status}" ]]; then sleep 120 exit 0 else seconds_left="$((${seconds_left} - ${POLL_INTERVAL}))" sleep ${POLL_INTERVAL} fi done # Time exceeded here exit 1