Created
March 13, 2018 14:56
-
-
Save aarondodd/76968a1a745717669bf88269191711fd to your computer and use it in GitHub Desktop.
scale an aurora cluster writer node
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 characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment