Skip to content

Instantly share code, notes, and snippets.

Created April 15, 2015 00:27
Show Gist options
  • Save anonymous/412e78df373f346a2dca to your computer and use it in GitHub Desktop.
Save anonymous/412e78df373f346a2dca to your computer and use it in GitHub Desktop.

Parse AWS IP ranges

Write a simple script to take the AWS IP ranges from https://ip-ranges.amazonaws.com/ip-ranges.json and output the range and location for each range in CSV format, e.g.:

23.20.0.0/14,"CA, US"
27.0.0.0/22,"Tokyo, JP"
...

You can use the following JSON to map from AWS region to location:

{
    "ap-northeast-1": "Tokyo, JP",
    "ap-southeast-1": "SG",
    "ap-southeast-2": "Sydney, AU",
    "eu-central-1": "Frankfurt, DE",
    "eu-west-1": "IE",
    "sa-east-1": "Sao Paulo, BR",
    "us-east-1": "VA, US",
    "us-west-1": "CA, US",
    "us-west-2": "OR, UA"
}

Coffee script is preferred, but you can use whatever you're comfortable with. Please put the script on github as a gist and send me the link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment