This 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 '
' ' ')
Related info:
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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…