如何根据其状态从AWS控制台查询图像AMI:可通过Python boto3使用? [英] How to Query Images AMI's from AWS Console based on their status : Available using Python boto3?

查看:120
本文介绍了如何根据其状态从AWS控制台查询图像AMI:可通过Python boto3使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据其状态:可用从AWS控制台获取图像AMI的详细信息.

I need to get the Details of Images AMI's from AWS Console based on their State: Available.

当我尝试它被卡住并且不打印任何行时.

When I tried it is getting stuck and not printing any line.

Python代码1:

Python code 1:

conn = boto3.resource('ec2')
image = conn.describe_images()
print(image) # prints nothing
for img in image:
  image_count.append(img)
print("img count ->" + str(len(image_count)))
#prints nothing

此图像AMI是否有确切的关键字,请纠正我

Is there any exact keywords for this Image AMI's Please correct me

推荐答案

关于AMI的重要一点是要提供每个 AMI.

An important thing to realize about AMIs is that every AMI is provided.

如果仅希望列出属于您自己帐户的AMI,请使用Owners=self:

If you only wish to list the AMIs belonging to your own account, use Owners=self:

import boto3

ec2_client = boto3.client('ec2')

images = ec2_client.describe_images(Owners=['self'])

available = [i['ImageId'] for i in images['Images'] if i['State'] == 'available']

这篇关于如何根据其状态从AWS控制台查询图像AMI:可通过Python boto3使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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