Forked from huevos-y-bacon/aws_ec2_termination_protection.md
Created
July 4, 2020 02:25
-
-
Save gurbuzali/5546197d36bf8ce7aa4e36a1a1b07fd4 to your computer and use it in GitHub Desktop.
Enable or disable EC2 instance "Termination Protection" via AWS CLI (shell)
This file contains hidden or 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
# Loop through all EC2 instances and enable termination protection | |
for I in $(aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId]' --output text); do aws ec2 modify-instance-attribute --disable-api-termination --instance-id $I; done | |
# Loop through all EC2 instances and disable termination protection | |
for I in $(aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId]' --output text); do aws ec2 modify-instance-attribute --no-disable-api-termination --instance-id $I;done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment