如何使用一个命令自行终止EC2? [英] How do I self terminate an EC2 with one command?

查看:66
本文介绍了如何使用一个命令自行终止EC2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此命令应在任何EC2上均可使用.然后,如果它使用实例ID,则应该发现它.

This command should work on any EC2. Then if it uses the instance ID, it should discover it.

推荐答案

这是您必须使用的AWS CLI命令.

This is the AWS CLI command you have to use.

aws ec2 terminate-instances --instance-ids 'curl http://169.254.169.254/latest/meta-data/instance-id'

如果启用了终止保护,则可以先从命令行禁用它,然后再使用上述命令.

If you have Termination protection on you can disable it first from the command line and then use above command.

aws ec2-modify-instance-attribute --disable-api-termination false INSTANCEID

这篇关于如何使用一个命令自行终止EC2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆