有没有办法使用Boto3列出停止的EC2实例? [英] Is there a way to list stopped EC2 instances using Boto3?

查看:58
本文介绍了有没有办法使用Boto3列出停止的EC2实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过使用 describe_instance_status 方法,如下所示.但是它不会返回任何已停止的EC2实例.显然,它根本无法识别任何已停止的实例.是否可以使用describe_instance_status方法列出所有已停止的EC2实例?谢谢!:)

I have already tried using describe_instance_status method like in below. But it does not return any of the stopped EC2 instances. Apparently, it does not identify any stopped instances at all. Is it possible to use describe_instance_status method to list down all the stopped EC2 instances? Thanks! :)

response_one = ec2.describe_instance_status(Filters=[
    {
        'Name': 'instance-state-name',
        'Values': [
            'stopped',
            'running'
        ]
    },
],

)

print(response_one)

推荐答案

使用,如果您有大量实例,请使用

and if you have a large number of instances, use the paginator

这篇关于有没有办法使用Boto3列出停止的EC2实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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