Created
May 27, 2016 15:30
-
-
Save alertedsnake/b7dc834510cf9883c84b3cfb286397b5 to your computer and use it in GitHub Desktop.
Kill all servers in an AWS Autoscaling Group
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
#!/bin/bash | |
# | |
# Note that this requires the really cool command-line tool 'jq' | |
# | |
if [ -z "$1" ]; then | |
echo "as_kill_instances [group]" | |
exit -1 | |
fi | |
instances=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $1 | jq -r .AutoScalingGroups[0].Instances[].InstanceId ) | |
for instance in $instances ; do | |
aws autoscaling terminate-instance-in-auto-scaling-group \ | |
--instance-id $instance \ | |
--no-should-decrement-desired-capacity | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment