Created
June 1, 2018 16:58
-
-
Save pbashyal-nmdp/a3604f6c910a29eb5de62ccc437605b6 to your computer and use it in GitHub Desktop.
Get CIDR of S3 service in us-east-1 region
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
#!/usr/bin/env python | |
# Usage: | |
# $ python ./useast1_s3_ips.py | |
# Update Date: 2018-06-01-12-26-19 | |
# | |
# 52.92.16.0/20 | |
# 52.216.0.0/15 | |
# 54.231.0.0/17 | |
# | |
import urllib2 | |
import json | |
ip_ranges_file = urllib2.urlopen("https://ip-ranges.amazonaws.com/ip-ranges.json") | |
ip_ranges_json = json.loads(ip_ranges_file.read()) | |
ip_ranges = ip_ranges_json['prefixes'] | |
create_date = ip_ranges_json['createDate'] | |
print("Update Date: %s\n" % create_date) | |
# Available Services | |
# "AMAZON" | |
# "ROUTE53_HEALTHCHECKS" | |
# "S3" | |
# "EC2" | |
# "ROUTE53" | |
# "CLOUDFRONT" | |
# "CODEBUILD" | |
# "AMAZON_CONNECT" | |
# "CLOUD9" | |
# "AMAZON" | |
# "ROUTE53_HEALTHCHECKS" | |
# "S3" | |
# "EC2" | |
# "CLOUDFRONT" | |
# | |
# Get CIDR of S3 service in us-east-1 region | |
us_east_1_s3_ips = [item['ip_prefix'] \ | |
for item in ip_ranges \ | |
if item['service'] == 'S3' and item['region'] == "us-east-1"] | |
for ip in us_east_1_s3_ips: | |
print(ip) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment