Skip to content

Instantly share code, notes, and snippets.

@knowsuchagency
Last active April 27, 2021 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knowsuchagency/ab1de2837397b88d03c7fe7f853a0fe6 to your computer and use it in GitHub Desktop.
Save knowsuchagency/ab1de2837397b88d03c7fe7f853a0fe6 to your computer and use it in GitHub Desktop.
get aws ip prefix whitelist
import requests
from pprint import pprint
def get_prefixes(region='us-east-2', service='AMAZON'):
resp = requests.get('https://ip-ranges.amazonaws.com/ip-ranges.json')
prefixes = resp.json()['prefixes']
if region:
prefixes = [p for p in prefixes if p['region'] == region]
if service:
prefixes = [p for p in prefixes if p['service'] == service]
return prefixes
pprint(get_prefixes())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment