Last active
January 10, 2022 22:14
-
-
Save lloesche/e73162a3c64116a1b5247c10be169a4e to your computer and use it in GitHub Desktop.
boto short to long region names for use with AWS pricing API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the long region names used by the AWS Pricing API | |
# | |
# There's currently no proper API to do this | |
# | |
# Example: | |
# print(SHORT_TO_LONG_REGIONS['us-west-2']) | |
# > US West (Oregon) | |
from pkg_resources import resource_filename | |
endpoints_file = resource_filename('botocore', 'data/endpoints.json') | |
with open(endpoints_file, 'r') as f: | |
endpoints = json.load(f) | |
SHORT_TO_LONG_REGIONS = {k: v['description'] for k, v in next(iter(endpoints.get('partitions', [])), {}).get('regions', {}).items()} | |
SHORT_TO_LONG_REGIONS['eu-west-1'] = 'EU (Ireland)' | |
SHORT_TO_LONG_REGIONS['eu-central-1'] = 'EU (Frankfurt)' | |
SHORT_TO_LONG_REGIONS['eu-north-1'] = 'EU (Stockholm)' | |
SHORT_TO_LONG_REGIONS['eu-west-2'] = 'EU (London)' | |
SHORT_TO_LONG_REGIONS['eu-west-3'] = 'EU (Paris)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for the heads up! I updated the Gist with your workaround. The discussion in that botocore issue is just sad to read 🙁