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

add a 15 second loop for creating the db and waiting before doing a f… #14813

Merged
merged 3 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ stages:
#build off prd variables
- export ECR_REPOSITORY_URI=${PRD_ACCOUNT_ID}.dkr.ecr.${PRD_REGION}.amazonaws.com
- export APP_DOCKER_FILE=Dockerfile
- export TASK_DOCKER_FILE=Dockerfile
- export TASK_DOCKER_FILE=Dockerfile.tasks
#TODO: update exp to prod
- export APP_ENVIRONMENT=prd

Expand Down
24 changes: 21 additions & 3 deletions scripts/rds-snapshot-app-db
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,35 @@ db_snapshot_identifier=$db_instance_identifier-$(date +%s)
readonly db_snapshot_identifier
readonly tags=("Key=Environment,Value=$environment" "Key=Tool,Value=$(basename "$0")")


echo
echo "Wait for concurrent database snapshots for ${db_instance_identifier} to complete before continuing ..."
time aws rds wait db-snapshot-completed --cli-read-timeout 2100 --cli-connect-timeout 2100 --db-instance-identifier "$db_instance_identifier"
time aws rds wait db-snapshot-completed --db-instance-identifier "$db_instance_identifier"


echo
echo "Create database snapshot for ${db_instance_identifier} with identifier ${db_snapshot_identifier}"
aws rds create-db-snapshot --cli-read-timeout 2100 --cli-connect-timeout 2100 --db-instance-identifier "$db_instance_identifier" --db-snapshot-identifier "$db_snapshot_identifier" --tags "${tags[@]}"


aws rds create-db-snapshot --db-instance-identifier "$db_instance_identifier" --db-snapshot-identifier "$db_snapshot_identifier" --tags "${tags[@]}"

#we want to loop while status is not available; check after initiating the create
while true; do
db_description=$(aws rds describe-db-snapshots --db-snapshot-identifier "$db_snapshot_identifier")
db_status=$(echo "${db_description}" | jq -r ".DBSnapshots[].Status")
echo "${db_snapshot_identifier} -- ${db_status}"
if [[ "${db_status}" == "available" ]]; then
break
fi
sleep 15
done


#unnecessary confirm but will leave in

echo
echo "Wait for current database snapshot ${db_snapshot_identifier} to complete before continuing ..."
time aws rds wait db-snapshot-completed --cli-read-timeout 2100 --cli-connect-timeout 2100 --db-snapshot-identifier "$db_snapshot_identifier"
time aws rds wait db-snapshot-completed --db-snapshot-identifier "$db_snapshot_identifier"

echo
echo "Describe the database snapshot ${db_snapshot_identifier}"
Expand Down
Loading