Created
November 14, 2016 18:07
-
-
Save edenzik/5d8cfc78d206e69c3a178bb39b1e37e9 to your computer and use it in GitHub Desktop.
Disable API protection on a lot of instances by filtering them via AWS Cli
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
# First, filter out the AMI ID's to a file (you should figure out a way to do this with xargs) | |
aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId] ' --output text --filters Name="instance-state-name",Values="stopped" | |
# Now loop through them | |
while read l; do aws ec2 modify-instance-attribute --disable-api-termination --instance-id $l; done < ami |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expanding on what Huevos says:
--disable-api-termination Prevents instance termination from the API
--no-disable-api-termination Allows instance termination from the API