aws-json-ips
Python library that resolves AWS-published IP ranges from the authoritative JSON source.
It downloads and parses https://ip-ranges.amazonaws.com/ip-ranges.json, extracts
all IPv4 and IPv6 CIDRs, and can optionally filter by AWS service, region, or
network border group.
Why JSON?
AWS publishes an authoritative machine-readable file with top-level metadata and separate IPv4/IPv6 prefix collections.
Each entry includes fields such as:
ip_prefixoripv6_prefixserviceregionnetwork_border_group
The top-level payload also includes:
syncTokencreateDate
This package reads that source directly.
Install
From PyPI
pip install aws-json-ips
Local Development
From the project root:
pip install -e .
Library Usage
from aws_json_ips import AWSIPQuery, get_aws_ip_cidrs
result = get_aws_ip_cidrs()
query = AWSIPQuery.from_cidrs(result.cidrs)
print(result.sync_token, result.create_date)
print(query.contains("3.5.140.0/22"))
print(query.collides("3.5.140.0-3.5.143.255"))
You can also filter the source data:
result = get_aws_ip_cidrs(services=("AMAZON", "S3"), regions=("us-east-1",))
result is a ResolutionResult with:
cidrs: sorted tuple of unique CIDR stringssync_token: source sync token from AWScreate_date: source publication date from AWSsource_url: JSON URL usedselected_prefix_count: number of selected IPv4 and IPv6 prefix entries
AWSIPQuery supports:
contains(value): full containment for IP, CIDR, or range string (start-end)collides(value): any overlap for IP, CIDR, or range string (start-end)- Specific methods:
contains_ip,contains_cidr,contains_range,collides_ip,collides_cidr,collides_range
Example Script
Run:
python examples/print_aws_ips.py
Flask JSON Server Example
Run:
python examples/flask_server.py
All endpoints return JSON.
Examples:
curl "http://127.0.0.1:5002/health"
curl "http://127.0.0.1:5002/metadata"
curl "http://127.0.0.1:5002/cidrs"
curl "http://127.0.0.1:5002/networks"
curl "http://127.0.0.1:5002/check?value=3.5.140.0/22"
curl "http://127.0.0.1:5002/check?value=3.5.140.0-3.5.143.255"
curl "http://127.0.0.1:5002/check/range?start=3.5.140.0&end=3.5.143.255"
Metadata
Release files for aws-json-ips 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aws_json_ips-0.1.0.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aws_json_ips-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / aws_json_ips-0.1.0.tar.gz
| Download URL | aws_json_ips-0.1.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7b159922a750fe400033f1c5fbc3e7b8d578c7c7ddfb1c3ca8fa3e1b791e7bf
|
|
BLAKE2b-256 checksum How to use checksums |
23e21c5fb8f60afb7d2e668f795403ac4dd0f1a9c71cc84e79eab3becd534c1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / aws_json_ips-0.1.0-py3-none-any.whl
| Download URL | aws_json_ips-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
899ac6a029aad5b2fa37685d1d3eec11a086e3175ecc615210f0505d77679acb
|
|
BLAKE2b-256 checksum How to use checksums |
24f44d4d7e9da249cb21227938fb1b8611a48c5535f2ba8d4b7ab4dc1229dcf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|