boto3 icon indicating copy to clipboard operation
boto3 copied to clipboard

Add human readable Name for region in describe_regions() or equivalent api call

Open darkmeadow opened this issue 7 years ago • 5 comments

  • Description

i would like to have a Api call for a Mapping of the Region Names used in the aws console to the region id (e.g: the describe_region() region_name return value) this could either be part of the describe_region or as a seperate api call.

  • Versions:

    • Python: 3.6.4 64 bit

    • Boto3: 1.5.10

  • current behaviour: describe_regions returns region id (e.g us-east-1) and endpoint

  • wanted behaviour: Api call returns region id , end point and the Name you also see in the aws console

darkmeadow avatar Jan 09 '18 11:01 darkmeadow

Makes sense. We have the metadata available stored in the botocore's endpoints.json to implement it as well. Marking as a feature request.

kyleknap avatar Jan 10 '18 02:01 kyleknap

I was looking for the same thing.

The information I was looking for is exactly what the botocore file endpoints.json has. It would be appropriate to list the endpoints by service in a call as describe_endpoints() or similar, and add the field region.description to the call describe_regions().

Until then, this is a possible temporary solution:

from pkg_resources import resource_filename
endpoint_file= resource_filename('botocore', 'data/endpoints.json')

with open(endpoint_file, 'r') as f:
    return json.load(f)

davidmoremad avatar May 14 '18 15:05 davidmoremad

Any progress on this? I'm currently using the Pricing API in Boto3, and when using a filter for the get_products method, the location field requires the region description e.g. "EU (Ireland)" instead of the region code (eu-west-1). Though a more appropriate fix would be to have the Pricing API support codes.

toringe avatar Aug 07 '18 09:08 toringe

I think this approach accomplishes the goal here: https://www.sentiatechblog.com/retrieving-all-region-codes-and-names-with-boto3

tim-finnigan avatar Mar 29 '22 21:03 tim-finnigan

In API data I also see a region in a strange format, for example usage type "AFS1-BoxUsage:r5d.24xlarge" where AFS1 is a region. I can not find a way to map my region name to that short variant, so I am not able to filter by usage type as this filter does not support regular expressions.

It would be great to have a mapping to all possible region variants.

stroykova avatar Jun 22 '22 11:06 stroykova

@tim-finnigan This approach currently works for some regions, but not for all of them. Regions in Europe have the longName parameter in SSM (e.g., "/aws/service/global-infrastructure/regions/eu-west-2/longName") as "Europe (region)" but the pricing API expects these regions to be named "EU (region)".

This can easily be checked by comparing the output from the following commands:

aws --region us-east-1 pricing get-products --filters Type=TERM_MATCH,Field=location,Value="EU (London)" --max-results 1 --service-code AmazonEC2

and

aws --region us-east-1 pricing get-products --filters Type=TERM_MATCH,Field=location,Value="Europe (London)" --max-results 1 --service-code AmazonEC2

emspoars avatar Oct 17 '22 21:10 emspoars