如何使用 aws 命令行工具获取 amazon ec2 实例列表?我检查了各种可用命令,但找不到适合此目的的命令。
答案1
aws ec2 describe-instances --filters "Name=instance-state-code,Values=16"
此过滤器的有效值:
The valid values are: 0 (pending), 16 (running), 32 (shutting-down), 48 (terminated), 64 (stopping), and 80 (stopped).
源自 CLI 文档:http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html
答案2
经典 ec2 客户端:
$ ec2-describe-instances
它有数十亿个过滤器,远超10个。
当前 awscli
$ aws ec2 describe-instances