Skip to content

Instantly share code, notes, and snippets.

@pbzona
Created December 19, 2023 22:30
Show Gist options
  • Save pbzona/431f9f0de5dd71b84b22a0882c52f7a8 to your computer and use it in GitHub Desktop.
Save pbzona/431f9f0de5dd71b84b22a0882c52f7a8 to your computer and use it in GitHub Desktop.
Get all IP ranges for us-east-1
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