阿里云地域帮助页面为您提供了完整的地域列表。这很有帮助。他们告诉您每个区域有多少个可用区也很有帮助。
没有帮助的是他们无法列出每个可用区的名称。花二十分钟的谷歌搜索时间太长了。阿里云/阿里云的完整可用区列表在哪里?
将其下拉。 它会吐出一堵 JSON 墙,因此使用 *nix 并拥有
jq 工具也很有帮助。 鉴于这一切,您所需要的只是这个简短的 shell 脚本:
#!/usr/bin/env bash
for region in $( aliyun ecs DescribeRegions | jq '.Regions.Region[].RegionId' )
do
echo $region
reg=$( echo $region | sed s/\"//g )
echo '---'
for zone in $( aliyun ecs DescribeZones --RegionId $reg | jq '.Zones.Zone[].ZoneId' | sort )
do
echo $zone
done
echo ''
done
其输出如下。
"cn-qingdao"
---
"cn-qingdao-b"
"cn-qingdao-c"
"cn-beijing"
---
"cn-beijing-a"
"cn-beijing-b"
"cn-beijing-c"
"cn-beijing-d"
"cn-beijing-e"
"cn-beijing-f"
"cn-beijing-g"
"cn-zhangjiakou"
---
"cn-zhangjiakou-a"
"cn-zhangjiakou-b"
"cn-huhehaote"
---
"cn-huhehaote-a"
"cn-huhehaote-b"
"cn-hangzhou"
---
"cn-hangzhou-b"
"cn-hangzhou-c"
"cn-hangzhou-d"
"cn-hangzhou-e"
"cn-hangzhou-f"
"cn-hangzhou-g"
"cn-hangzhou-h"
"cn-shanghai"
---
"cn-shanghai-a"
"cn-shanghai-b"
"cn-shanghai-c"
"cn-shanghai-d"
"cn-shanghai-e"
"cn-shanghai-f"
"cn-shenzhen"
---
"cn-shenzhen-a"
"cn-shenzhen-b"
"cn-shenzhen-c"
"cn-shenzhen-d"
"cn-hongkong"
---
"cn-hongkong-a"
"cn-hongkong-b"
"cn-hongkong-c"
"ap-northeast-1"
---
"ap-northeast-1a"
"ap-southeast-1"
---
"ap-southeast-1a"
"ap-southeast-1b"
"ap-southeast-1c"
"ap-southeast-2"
---
"ap-southeast-2a"
"ap-southeast-2b"
"ap-southeast-3"
---
"ap-southeast-3a"
"ap-southeast-3b"
"ap-southeast-5"
---
"ap-southeast-5a"
"ap-south-1"
---
"ap-south-1a"
"ap-south-1b"
"us-east-1"
---
"us-east-1a"
"us-east-1b"
"us-west-1"
---
"us-west-1a"
"us-west-1b"
"eu-west-1"
---
"eu-west-1a"
"eu-west-1b"
"me-east-1"
---
"me-east-1a"
"eu-central-1"
---
"eu-central-1a"
"eu-central-1b"
我在此 URL 中搜索我需要的所有内容(确保点击“所有产品”选项卡)
您可以通过以下方式请求:
https://ecs.aliyuncs.com/?Action=DescribeZones
&RegionId=cn-hangzhou
&InstanceChargeType=PostPaid
&SpotStrategy=NoSpot
&<Common request parameters>
Python 示例
import json
from aliyunsdkcore.client import AcsClient
from aliyunsdkvpc.request.v20160428.DescribeZonesRequest import DescribeZonesRequest
region = "cn-shanghai"
client = AcsClient(access_key, secret_key, region)
request = DescribeZonesRequest()
request.set_accept_format('json')
zones_list = json.loads(client.do_action_with_exception(request).decode('utf8'))
print(zones_list)
使用上面的 sdk,我还像这样查询区域:
aliyunsdkcore
正在作为依赖项安装
aliyunsdkvpc
无需安装
from aliyunsdkcore.endpoint.local_config_regional_endpoint_resolver import LocalConfigRegionalEndpointResolver
resolver = LocalConfigRegionalEndpointResolver()
regions_list = resolver.get_valid_region_ids_by_product(product_code='ecs')
print(regions_list)
的区域和可用区列表可以在支持的区域和可用区中找到。 还有一张纸条
重要: 下表描述了弹性计算服务支持的所有地域和可用区。每个云服务支持的区域和可用区可能有所不同。具体云服务支持的地域和可用区请参见该云服务的文档。
# Query the regions supported by ECS aliyun ecs DescribeRegions \ --AcceptLanguage en-US \ --output cols="RegionId,LocalName" rows="Regions.Region" num=true # List availability zones echo -e "\nRegion\t\t\tCount\tAZ" for region in $(aliyun ecs DescribeRegions --AcceptLanguage en-US | jq -r '.Regions.Region[].RegionId'); do zones=$(aliyun ecs DescribeZones --RegionId "${region}" | jq -r '[.Zones.Zone[].ZoneId] | sort') zones_count=$(jq -r 'length' <<< "${zones}") zones_list=$(jq -r 'join("\n\t\t\t\t")' <<< "${zones}") echo -e "${region}\t\t${zones_count}\t${zones_list}" done
Region Count AZ
cn-qingdao 2 cn-qingdao-b
cn-qingdao-c
cn-beijing 12 cn-beijing-a
cn-beijing-b
cn-beijing-c
cn-beijing-d
cn-beijing-e
cn-beijing-f
cn-beijing-g
cn-beijing-h
cn-beijing-i
cn-beijing-j
cn-beijing-k
cn-beijing-l
cn-zhangjiakou 3 cn-zhangjiakou-a
cn-zhangjiakou-b
cn-zhangjiakou-c
cn-huhehaote 2 cn-huhehaote-a
cn-huhehaote-b
cn-wulanchabu 3 cn-wulanchabu-a
cn-wulanchabu-b
cn-wulanchabu-c
cn-hangzhou 8 cn-hangzhou-b
cn-hangzhou-e
cn-hangzhou-f
cn-hangzhou-g
cn-hangzhou-h
cn-hangzhou-i
cn-hangzhou-j
cn-hangzhou-k
cn-shanghai 11 cn-shanghai-a
cn-shanghai-b
cn-shanghai-c
cn-shanghai-d
cn-shanghai-e
cn-shanghai-f
cn-shanghai-g
cn-shanghai-k
cn-shanghai-l
cn-shanghai-m
cn-shanghai-n
cn-nanjing 1 cn-nanjing-a
cn-shenzhen 6 cn-shenzhen-a
cn-shenzhen-b
cn-shenzhen-c
cn-shenzhen-d
cn-shenzhen-e
cn-shenzhen-f
cn-heyuan 2 cn-heyuan-a
cn-heyuan-b
cn-guangzhou 2 cn-guangzhou-a
cn-guangzhou-b
cn-fuzhou 1 cn-fuzhou-a
cn-wuhan-lr 1 cn-wuhan-lr-a
cn-chengdu 2 cn-chengdu-a
cn-chengdu-b
cn-hongkong 3 cn-hongkong-b
cn-hongkong-c
cn-hongkong-d
ap-northeast-1 3 ap-northeast-1a
ap-northeast-1b
ap-northeast-1c
ap-northeast-2 1 ap-northeast-2a
ap-southeast-1 3 ap-southeast-1a
ap-southeast-1b
ap-southeast-1c
ap-southeast-3 2 ap-southeast-3a
ap-southeast-3b
ap-southeast-6 1 ap-southeast-6a
ap-southeast-5 3 ap-southeast-5a
ap-southeast-5b
ap-southeast-5c
ap-southeast-7 1 ap-southeast-7a
us-east-1 2 us-east-1a
us-east-1b
us-west-1 2 us-west-1a
us-west-1b
eu-west-1 2 eu-west-1a
eu-west-1b
me-east-1 1 me-east-1a
me-central-1 2 me-central-1a
me-central-1b
eu-central-1 3 eu-central-1a
eu-central-1b
eu-central-1c