Skip to content

Instantly share code, notes, and snippets.

@ShawInnes
Created August 28, 2016 06:44
Show Gist options
  • Save ShawInnes/7b5789d22d1143958eca4d5ca741dd1d to your computer and use it in GitHub Desktop.
Save ShawInnes/7b5789d22d1143958eca4d5ca741dd1d to your computer and use it in GitHub Desktop.
Python Script to Nicely format AWS IP Ranges
import requests
from prettytable import PrettyTable
url_ips = requests.get('https://ip-ranges.amazonaws.com/ip-ranges.json')
ip_range = url_ips.json()
table = PrettyTable(['service', 'region', 'ip_prefix'])
table.align = "l"
for prefix in ip_range['prefixes']:
table.add_row([prefix['service'], prefix['region'], prefix['ip_prefix']])
print(table)
@ShawInnes
Copy link
Author

requires PTable pip to be installed

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