Created
August 18, 2011 06:18
-
-
Save dustincurrie/1153466 to your computer and use it in GitHub Desktop.
Run a command on all instances attached to an AWS ELB
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 | |
# Runs a command on all instances attached to a load balancer | |
# Elastic Load Balancer Tools from http://aws.amazon.com/developertools/2536 | |
ELB=prod-axs-aeg | |
COMMAND='service varnish restart' | |
INSTANCES=$(elb-describe-instance-health $ELB | awk -F " " '{print $2}') | |
for INSTANCEID in ${INSTANCES} ; do | |
INSTANCEURL=$(ec2-describe-instances $INSTANCEID | egrep '^INSTANCE' | awk -F " " '{print $4}') | |
$SSH -l root $INSTANCEURL $COMMAND | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment