Last active
December 4, 2016 19:11
-
-
Save acsrujan/607bab159afcd634c19c to your computer and use it in GitHub Desktop.
Deploying to an ELB backed application when you have a deployment script to do on one instance.
This file contains 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
$LOAD_BALANCER_NAME="" | |
Instance_ids=`aws elb describe-load-balancers --load-balancer-name $LOAD_BALANCER_NAME --query "LoadBalancerDescriptions[*].{ID:LoadBalancerName,InstanceId:Instances[*].InstanceId}[*]. {ELB:ID,InstanceId:InstanceId[*]}" --output=json |jq -r ".[].InstanceId|@csv"` | |
for $INSTANCE_ID in ${Instance_ids[@]}: | |
do | |
private_ip=`aws ec2 describe-instances --instance-id $id |jq -r '.Reservations[].Instances[] | .PrivateIpAddress'` | |
aws elb deregister-instances-from-load-balancer --load-balancer-name $LOAD_BALANCER_NAME --instances $INSTANCE_ID | |
`ssh $username@$private_ip` < deployment_script.sh | |
aws elb register-instances-with-load-balancer --load-balancer-name $LOAD_BALANCER_NAME --instances $INSTANCE_ID | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment