Last Updated on May 2, 2021
I tried accessing the AWS Price List API using the Singapore region (ap-southeast-1) but it resulted the error Could not connect to the endpoint URL: "https://api.pricing.ap-southeast-1.amazonaws.com/"
.
But whenever I use the N. Virginia Region (us-east-1) it works without any issues.
So on what regions will the AWS Price List API work?
TL;DR – AWS Price List API only works in N. Virginia (us-east-1) and Mumbai (ap-south-1) regions.
To answer this question I wrote a Python script that uses boto3 to check whether the AWS Price List API will throw an exception for each region.
The code below is a mix of the AWS List Regions and getting the region name for AWS Price List API scripts that we wrote.
import boto3
import json
from pkg_resources import resource_filename
def get_region_name(region_code):
endpoint_file = resource_filename('botocore', 'data/endpoints.json')
with open(endpoint_file, 'r') as f:
endpoint_data = json.load(f)
region_name = endpoint_data['partitions'][0]['regions'][region_code]['description']
region_name = region_name.replace('Europe', 'EU')
return region_name
if __name__ == "__main__":
ec2_client = boto3.client('ec2')
ec2_response = ec2_client.describe_regions(AllRegions=True)
for region in ec2_response['Regions']:
region_code = region['RegionName']
pricing_client = boto3.client('pricing', region_name=region_code)
try:
pricing_response = pricing_client.describe_services()
print('PASS', '\t', region_code, '\t', get_region_name(region_code))
except:
print('FAIL', '\t', region_code, '\t', get_region_name(region_code))
Output (arranged alphabetically)
FAIL af-south-1 Africa (Cape Town)
FAIL ap-east-1 Asia Pacific (Hong Kong)
FAIL ap-northeast-1 Asia Pacific (Tokyo)
FAIL ap-northeast-2 Asia Pacific (Seoul)
FAIL ap-northeast-3 Asia Pacific (Osaka)
PASS ap-south-1 Asia Pacific (Mumbai)
FAIL ap-southeast-1 Asia Pacific (Singapore)
FAIL ap-southeast-2 Asia Pacific (Sydney)
FAIL ca-central-1 Canada (Central)
FAIL eu-central-1 EU (Frankfurt)
FAIL eu-north-1 EU (Stockholm)
FAIL eu-south-1 EU (Milan)
FAIL eu-west-1 EU (Ireland)
FAIL eu-west-2 EU (London)
FAIL eu-west-3 EU (Paris)
FAIL me-south-1 Middle East (Bahrain)
FAIL sa-east-1 South America (Sao Paulo)
PASS us-east-1 US East (N. Virginia)
FAIL us-east-2 US East (Ohio)
FAIL us-west-1 US West (N. California)
FAIL us-west-2 US West (Oregon)
From the result above we can conclude that AWS Price List API will only work for the Mumbai Region (ap-south-1) and N. Virginia Region (us-east-1). It will not work in other regions.