Created
December 19, 2023 22:30
-
-
Save pbzona/431f9f0de5dd71b84b22a0882c52f7a8 to your computer and use it in GitHub Desktop.
Get all IP ranges for us-east-1
This file contains hidden or 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 | |
import json | |
# URL of the Amazon IP ranges JSON file | |
url = "https://ip-ranges.amazonaws.com/ip-ranges.json" | |
# Send a request to get the file | |
response = requests.get(url) | |
# Load the JSON data from the response | |
data = json.loads(response.text) | |
# Filter for us-east-1 IP ranges | |
us_east_1_ranges = [entry['ip_prefix'] for entry in data['prefixes'] if entry['region'] == 'us-east-1'] | |
# Print the IP ranges | |
for ip_range in us_east_1_ranges: | |
print(ip_range) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment