Skip to content

Instantly share code, notes, and snippets.

@sidcpatel
Forked from pahud/gen_cf_cidr.py
Last active November 21, 2017 03:38
Show Gist options
  • Save sidcpatel/d0cdd06bc82b80c0bf81f5787a24ed65 to your computer and use it in GitHub Desktop.
Save sidcpatel/d0cdd06bc82b80c0bf81f5787a24ed65 to your computer and use it in GitHub Desktop.
generate AWS CloudFront IP/CIDR range
#!/usr/bin/env python
import requests, json, datetime
d = requests.get('https://ip-ranges.amazonaws.com/ip-ranges.json').text
l = json.loads(d)
print "# Amazon CloudFront IP Ranges"
print "# Generated at " + str(datetime.datetime.now())
for ip_range in [x['ip_prefix'] for x in l['prefixes'] if x['service']=='CLOUDFRONT' ]:
print "set_real_ip_from " + ip_range + ";"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment