Skip to main content

Generates a list of AWS regions closest to each other

Project description

AWS Region Proximity

Print a JSON dictionary where the key is an AWS region code name (us-west-2, eu-central-1, etc.), and the value is a list of regions in order of their physical proximity to the region. You may optionally pass in a list of region code names that you have a copy of the resource in. The results will have the same keys, but the lists will only contain the regions you specified.

Why?

Say you have S3 buckets being cross-region-replicated in us-west-2, eu-central-1, and ap-southeast-1 and you want to put a Cloudfront distribution in front of them. You can use a Lambda@Edge with an Origin Request trigger to change the origin that Cloudfront will pull a resource from. Lambda@Edge has the environment variable AWS_REGION, which will tell you the closest region to where your Lambda is executing. You could then use the list generated by this program to help find the nearest origin that can handle the request.

For example, a request comes in to the DFW edge location. The environment variable AWS_REGION is "us-east-1" (the AWS region associated with the edge location of DFW). You don't have a copy of the resource in us-east-1, but you do have a copy in us-west-2. So that can be the copy you return (as opposed to your copy in eu-central-1 or ap-southeast-1).

Install

pip install aws-region-proximity

Usage

Get the Closest Regions for All Regions

aws-regions

Output:

{
    "us-east-1": [
        "us-east-1",
        "us-east-2",
        "ca-central-1",
        "us-west-2",
        "us-west-1",
        "eu-west-1",
        "eu-west-2",
        "eu-west-3",
        "eu-central-1",
        "eu-north-1",
        "eu-south-1",
        "sa-east-1",
        "ap-northeast-1",
        "me-south-1",
        "cn-north-1",
        "ap-northeast-2",
        "cn-northwest-1",
        "af-south-1",
        "ap-south-1",
        "ap-east-1",
        "ap-southeast-1",
        "ap-southeast-2"
    ],
    ...
    "cn-northwest-1": [
        "cn-northwest-1",
        "cn-north-1",
        "ap-east-1",
        "ap-northeast-2",
        "ap-northeast-1",
        "ap-south-1",
        "ap-southeast-1",
        "me-south-1",
        "eu-north-1",
        "eu-central-1",
        "eu-south-1",
        "eu-west-2",
        "eu-west-3",
        "eu-west-1",
        "ap-southeast-2",
        "us-west-2",
        "us-west-1",
        "ca-central-1",
        "us-east-2",
        "us-east-1",
        "af-south-1",
        "sa-east-1"
    ]
}

Get Closest Specified Regions per Region

For when you have copies in a limited number of regions and just want to see your closest available region given some other region.

aws-regions us-west-2 eu-central-1 ap-southeast-1

Output

{
    "us-east-1": [
        "us-west-2",
        "eu-central-1",
        "ap-southeast-1"
    ],
    "us-east-2": [
        "us-west-2",
        "eu-central-1",
        "ap-southeast-1"
    ],
    "us-west-1": [
        "us-west-2",
        "eu-central-1",
        "ap-southeast-1"
    ],
    "us-west-2": [
        "us-west-2",
        "eu-central-1",
        "ap-southeast-1"
    ],
    "eu-west-1": [
        "eu-central-1",
        "us-west-2",
        "ap-southeast-1"
    ],
    ...
    "cn-north-1": [
        "ap-southeast-1",
        "eu-central-1",
        "us-west-2"
    ],
    "cn-northwest-1": [
        "ap-southeast-1",
        "eu-central-1",
        "us-west-2"
    ]
}

There is still a key for every region, but the list of the closest regions is limited to those specified on the command line.

From Whence Comes This Data?

This Gist: https://gist.github.com/atyachin/a011edf76df66c5aa1eac0cdca412ea9

Instead of geographic coordinates, it'd probably be better if we sorted by actual inter-region latency, like what this table has: https://www.cloudping.co/grid

Put it on the TODO list.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-region-proximity-0.1.3.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

aws_region_proximity-0.1.3-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file aws-region-proximity-0.1.3.tar.gz.

File metadata

  • Download URL: aws-region-proximity-0.1.3.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

File hashes

Hashes for aws-region-proximity-0.1.3.tar.gz
Algorithm Hash digest
SHA256 deb6f4885e414d6237d183718826410b8b06075f0059d1385c6eb868d15b7188
MD5 4a9cb5bcd0c768f8c2bf787c0f2701ab
BLAKE2b-256 237d1a2555bacb586fc52e087bd458db356255fba795809aa911b395577485aa

See more details on using hashes here.

File details

Details for the file aws_region_proximity-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: aws_region_proximity-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

File hashes

Hashes for aws_region_proximity-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 38fd94cbcb74f9fb9953689cf1b459c96748d4cba80c19cac76a8d92011347fc
MD5 c13fb08583382f23d83e471c1895d6c8
BLAKE2b-256 7e43168f700c02aacdffc303ae11d4031b9f5b072adae8e2376dd423f4b44264

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page