boto3-区域名称和服务名称

时间:2021-05-19 10:48:00

标签: amazon-web-services boto3

如何获取所有区域的列表,例如:us-east-1。如何使用 boto3 获取所有区域的列表。 (我并不是要像已经询问的那样尝试获取特定服务的可用区域)

另外,我如何使用 boto3 获取 AWS 提供的所有服务的名称,以便稍后在创建资源或客户端时使用它们。

我问这个问题是因为创建会话或资源或客户端时,我必须指定这些内容,但我不知道如何找到要传递的确切值。

1 个答案:

答案 0 :(得分:2)

对于区域,您可以获得的最接近的是 describe_regions

ec2 = boto3.client('ec2')
response = [region['RegionName'] for region in ec2.describe_regions(AllRegions=True)['Regions']]

print(response)

给出:

['af-south-1', 'eu-north-1', 'ap-south-1', 'eu-west-3', 'eu-west-2', 'eu-south-1', 'eu-west-1', 'ap-northeast-3', 'ap-northeast-2', 'me-south-1', 'ap-northeast-1', 'sa-east-1', 'ca-central-1', 'ap-east-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-central-1', 'us-east-1', 'us-east-2', 'us-west-1', 'us-west-2']

对于服务 - 我认为没有任何 API 调用。您可以从 here 中抓取它们,但这不会涉及 boto3。

相关问题