Created
April 5, 2018 01:58
-
-
Save iocat/b06b464abe917e82e2b9c65cfcdafa80 to your computer and use it in GitHub Desktop.
Remove all EC2 instances on the currently selected region (set up with aws configure)
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
INSTANCES=`aws ec2 describe-instances | grep InstanceId | awk '{ print $2 }' | tr -d '",'` | |
for INSTANCE in $INSTANCES; do | |
aws ec2 modify-instance-attribute --no-disable-api-termination --instance-id $INSTANCE | |
aws ec2 terminate-instances --instance-ids $INSTANCE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment