amazon-web-services - How to find who created an AWS AMI?
问题描述
I created a boto3 script
1 import boto3
2
3 #STATUSES = ( 'available', 'pending' )
4 REGIONS = ('us-west-1', 'us-east-1', 'us-west-2')
5 REGIONS_H = ('N. California', 'N. Virginia', 'Oregon')
6
7 for i in range(len(REGIONS)):
8 region = REGIONS[i]
9 region_h = REGIONS_H[i]
10 print()
11 print("Images in {}".format(region_h))
12 print("-----------------------")
13 rds = boto3.setup_default_session(region_name=region)
14 rds = boto3.client('rds')
15
16 ec2 = boto3.resource('ec2')
17 images = ec2.images.filter(Owners=['self'])
18 for image in images:
19 print("[{}] ( {} {} {} {} )".format(image.state, image.id, image.image_type, image.architecture, image.description, image.platform))
that gives me the following output (trancated for bravity):
Images in N. California
-----------------------
[available] ( ami-02efeb026dba996f8 machine x86_64 Base system for testing Progressive install )
[available] ( ami-046bd9fc47f29a58f machine x86_64 bb-rhel7-install-5 )
[available] ( ami-04c2959b96500208c machine x86_64 bb-ubuntu-install-3 )
Is there a way to add to line 19, so I could display who created the AMI?
解决方案
image.owner_id
将返回映像所有者的 AWS 账户 ID。参考这个链接。
推荐阅读
- python-3.x - 获取文件路径并在顶级小部件的条目上显示它不起作用
- javascript - 除非我 sudo,否则不能将其他端口用于 nodejs 应用程序
- express - 针对快速服务器的 Axios 发布请求成功使用图像,使用 .mp4 文件失败
- go - PromQL 查询以绘制传入请求的速率
- css - Flex 盒子水平对齐
- c# - 这是使用 ConfigureAwait(false) 的正确方法吗?
- amazon-web-services - IAM 权限策略是否可以用于允许访问跨账户资源?
- java - 在测验应用程序中显示结果 + 不正确/正确的对话框
- python - 使用带有--no-console的pyinstaller时如何将错误信息记录到文件中?
- unit-testing - Netbeans 11.2 未找到测试