Skip to content

Instantly share code, notes, and snippets.

@iocat
Created April 5, 2018 01:58
Show Gist options
  • Save iocat/b06b464abe917e82e2b9c65cfcdafa80 to your computer and use it in GitHub Desktop.
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)
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