python - 如何使用 python 查找 AMI 的 AWS 区域?
问题描述
我正在尝试在 Amazon Web Services 中为 ami 找到一个区域,我只知道 ami id,最好使用 python。怎么做?
解决方案
这是片段
import boto3
ami_id = "HERE IS YOUR AMI ID"
client = boto3.client('ec2')
ec2 = boto3.resource('ec2')
regions = client.describe_regions()
for region in regions["Regions"]:
region_name = region["RegionName"]
print(region_name)
try:
image = ec2.Image(ami_id)
response = image.describe_attribute(Attribute='description')
print("Found ami in region {}".format(region_name))
break
except:
print("Ami doesnt exist in {} region".format(region_name))
推荐阅读
- python - Python 精度处理
- nginx - Nginx 404 不工作,重定向到主页
- tensorflow - TF Object detection API mAP 计算貌似错误
- powershell - Powershell 脚本协助
- integration - Duoplane 和 Quick book 会计应用程序的集成
- python - Use API to write to json file
- javascript - Javascript中的图形实现
- javascript - 如何在不更改主文件的情况下撤消 Core.JS 代码?
- css - CSS 上的视频
- assembly - 在 MOV 和 LEA 指令之后如何确定 AX 中的结果