How can I kill all my instances from the command line? Is there a command for this or must I script it?
See Question&Answers more detail:osHow can I kill all my instances from the command line? Is there a command for this or must I script it?
See Question&Answers more detail:osThis is an old question but thought I'd share a solution for AWS CLI:
aws ec2 terminate-instances --instance-ids $(aws ec2 describe-instances --filters "Name=instance-state-name,Values=pending,running,stopped,stopping" --query "Reservations[].Instances[].[InstanceId]" --output text | tr '
' ' ')
If hackers have disabled accidental instance termination, first run this command:
aws ec2 describe-instances --filters "Name=instance-state-name,Values=pending,running,stopped,stopping" --query "Reservations[].Instances[].[InstanceId]" --output text | xargs --delimiter '
' --max-args=1 aws ec2 modify-instance-attribute --no-disable-api-termination --instance-id