Registry / aws / awsipranges

awsipranges

JSON →
library0.3.3pypypi✓ verified 85d ago

AWS IP Ranges is a Python library for working with AWS IP address ranges natively. It provides tools to download, parse, and query the AWS IP address ranges JSON data (from https://ip-ranges.amazonaws.com/ip-ranges.json). Current version is 0.3.3, released periodically.

pip install awsipranges
INSTALL
IMPORT
SIG · AWSIPRANGES
A
awsipranges
awspythonv0.3.3
Install
1.6s avg
Import
135ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.140s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.130s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AWSIPPrefixes
from awsipranges import AWSIPPrefixes
The main class to download and parse the IP ranges.

Download the AWS IP ranges JSON and filter by region and service.

from awsipranges import AWSIPPrefixes # Download current AWS IP ranges prefixes = AWSIPPrefixes() prefixes.download() # Filter for us-east-1 region, EC2 service ec2_us_east1 = prefixes.filter(regions=['us-east-1'], services=['EC2']) print(f"Found {len(ec2_us_east1)} prefixes for EC2 in us-east-1") # Access the MD5 hash (available since 0.3.0) print(f"MD5 hash: {prefixes.md5}")
awsipranges --version
Debug
Known issues
gotchaThe filter() method returns a list of IP prefixes, not an AWSIPPrefixes object. Do not attempt to chain further filter calls.
fix
Store the result in a variable and iterate over it directly.
affects: all
deprecatedThe `sync()` method is deprecated. Use `download()` instead.
fix
Replace `prefixes.sync()` with `prefixes.download()`.
affects: >=0.3.0
gotchaThe library requires Python >=3.7,<4.0. Using Python 3.6 or 4.0+ will cause install failures.
fix
Ensure your Python version is in the supported range (3.7-3.11 tested).
affects: all
Errors
Common errors & fixes
NameError: name 'AWSIPPrefixes' is not defined
Importing incorrectly (e.g., `import awsipranges` and then `awsipranges.AWSIPPrefixes` without the class import), or package not installed.
fix
Use `from awsipranges import AWSIPPrefixes`.
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='ip-ranges.amazonaws.com', port=443): Max retries exceeded
No internet access or the AWS IP ranges endpoint is unreachable (e.g., due to firewall or network issues).
fix
Ensure the machine has internet access and can reach https://ip-ranges.amazonaws.com/. Alternatively, use a proxy with the `proxies` parameter.
AttributeError: 'list' object has no attribute 'filter'
Calling `filter()` on the result of a previous `filter()` call, but `filter()` returns a list.
fix
Do not chain filters. Instead, save the first result and apply a second filter manually: `result = prefixes.filter(...); second = [p for p in result if ...]`.
Upgrade
Version history
0.3.3latest on PyPI · released Feb 10, 2022
Audit
Dependencies
requestsrequiredHTTP client for downloading the JSON data
Agent activity
23 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources