Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Created August 4, 2017 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkuchiki/3c642f2ba3eafdeea67264f8f7190ca6 to your computer and use it in GitHub Desktop.
Save tkuchiki/3c642f2ba3eafdeea67264f8f7190ca6 to your computer and use it in GitHub Desktop.
Aurora Writer のインスタンスサイズを変更した後、もう一度 Writer にする
#!/bin/bash
set -u
INSTANCE="${1}"
SIZE="${2}"
CLUSTER="${3}"
echo "modify db instance: ${INSTANCE} ${SIZE}"
aws rds modify-db-instance --db-instance-identifier ${INSTANCE} --db-instance-class ${SIZE} --apply-immediately
# modify-db-instance 直後にステータスを見ると available になるので sleep する
sleep 300
while :; do
status=$(aws rds describe-db-instances --db-instance-identifier ${INSTANCE} | jq -r .DBInstances[].DBInstanceStatus)
[ "${status}" = "available" ] && break
echo -ne "."
sleep 60
done
echo "modified db instance: ${INSTANCE} ${SIZE}"
aws rds failover-db-cluster --db-cluster-identifier ${CLUSTER} --target-db-instance-identifier ${INSTANCE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment