【发布时间】:2020-03-09 12:48:16
【问题描述】:
我正在尝试使用 API 在特定可用区域中查找所有受支持的实例。
我在网页中有列表,例如 https://docs.aws.amazon.com/sagemaker/latest/dg/instance-types-az.html
我希望通过 API 实现这一点
【问题讨论】:
标签: amazon-web-services amazon-ec2
我正在尝试使用 API 在特定可用区域中查找所有受支持的实例。
我在网页中有列表,例如 https://docs.aws.amazon.com/sagemaker/latest/dg/instance-types-az.html
我希望通过 API 实现这一点
【问题讨论】:
标签: amazon-web-services amazon-ec2
来自DescribeInstanceTypeOfferings - Amazon Elastic Compute Cloud:
返回提供的所有实例类型的列表。可以按位置(区域或可用区)过滤结果。如果不指定位置,则返回当前 Region 提供的实例类型。
以下是一些示例 Python 代码,用于显示特定 AZ 中的实例类型:
import boto3
ec2_client = boto3.client('ec2')
response = ec2_client.describe_instance_type_offerings(LocationType='availability-zone',Filters=[{'Name': 'location', 'Values':['ap-southeast-2a']}])
for offering in response['InstanceTypeOfferings']:
print(offering['InstanceType'])
【讨论】: