Shell script to start Amazon RDS in different regions

4 Apr

A shell script to create Amazon RDS instances in different data center regions.

regions=( us-east-1 us-west-2 us-west-1 eu-west-1 ap-southeast-1 ap-northeast-1 sa-east-1 )

for REGION in ${regions[@]}
do
	rds-create-db-instance test  --allocated-storage  10  --db-instance-class db.m1.large  --engine MySQL    --master-user-password  testtest  --master-username test --region $REGION
	rds-authorize-db-security-group-ingress default --cidr-ip 0.0.0.0/0 --region $REGION
done

sleep 60

for REGION in ${regions[@]}
do
	rds-describe-db-instances --region $REGION
done

sleep 300

for REGION in ${regions[@]}
do
	rds-delete-db-instance test --skip-final-snapshot  --region $REGION
	rds-revoke-db-security-group-ingress default --cidr-ip 0.0.0.0/0 --region $REGION
done

UPDATE: Corrected “rds-describe-db-instances” command and CIDR range, added all AWS regions on April 25 2012.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: