Last active
March 5, 2020 01:38
-
-
Save qrkourier/97e0e3539b6dde1163a1531adf7192a2 to your computer and use it in GitHub Desktop.
roll RDS instance CAs and bounce immediately
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 | |
set -e -u -o pipefail | |
aws --output text ec2 describe-regions | while read REG ENDPOINT OPT REGION; do | |
aws --region $REGION rds describe-db-instances | \ | |
jq -r '[.DBInstances[]|select(.CACertificateIdentifier == "rds-ca-2015")|{id:.DBInstanceIdentifier, az:.AvailabilityZone,engine:.Engine, user:.MasterUsername, end:.Endpoint.Address}]' | |
done | |
read -p "Roll cert and bounce these instances? <ENTER> to proceed, Ctrl-c to cancel: " | |
aws --output text ec2 describe-regions | while read REG ENDPOINT OPT REGION; do | |
aws --region $REGION rds describe-db-instances | jq -r '.DBInstances[]|select(.CACertificateIdentifier == "rds-ca-2015")|.DBInstanceIdentifier'|while read;do | |
aws --region $REGION rds modify-db-instance \ | |
--db-instance-identifier $REPLY \ | |
--ca-certificate-identifier rds-ca-2019 \ | |
--apply-immediately | jq -r .DBInstance.DBInstanceIdentifier | while read DB; do echo "$REGION,${DB}";done | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment