Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- instance_size=$1
- cluster_id="mycoolcluster-xxxx"
- primary_node="mycoolcluster-node"
- region="us-east-1"
- pending_status=""
- check_for='"PendingModifiedValues": {},'
- aws rds modify-db-instance --db-instance-identifier "${primary_node}" --db-instance-class "${instance_size}" --apply-immediately --region "${region}"
- echo "Checking status for ${primary_node}..."
- until [ "${pending_status}" != "" ]; do
- pending_status=$(aws rds describe-db-instances --db-instance-identifier "${primary_node}" --region "${region}" --output json | grep "${check_for}")
- echo "${primary_node} still pending changes, waiting."
- sleep 10
- done
- echo "Failing back to ${primary_node}"
- # sometimes it seems pending status is removed but node is not yet ready for failback (likely pending-reboot but not shown in CLI response)
- # so if an error occurs, keep trying (there's probably a better way to do this)
- while [ $? -ne 0 ]; do
- aws rds failover-db-cluster --db-cluster-identifier "${cluster_id}" --target-db-instance-identifier "${primary_node}" --region "${region}"
- sleep 5
- done
Add Comment
Please, Sign In to add comment