Skip to content

Instantly share code, notes, and snippets.

@shaiesto
Last active July 11, 2018 08:32
Show Gist options
  • Save shaiesto/d8644c2105a5c430e432ae45b6d48762 to your computer and use it in GitHub Desktop.
Save shaiesto/d8644c2105a5c430e432ae45b6d48762 to your computer and use it in GitHub Desktop.
aws ec2:disable termination protection on all stopped instances
#!/bin/bash
for i in $(aws ec2 describe-instances --query 'Reservations[?Instances.State.Name=='stopped'].Instances[].[InstanceId]' --output text); do
aws ec2 modify-instance-attribute --no-disable-api-termination --instance-id $i --dry-run
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment