Last active
April 27, 2021 20:06
-
-
Save knowsuchagency/ab1de2837397b88d03c7fe7f853a0fe6 to your computer and use it in GitHub Desktop.
get aws ip prefix whitelist
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
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