Resolve AWS IP CIDR ranges from the authoritative published JSON source
Project description
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"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aws_json_ips-0.1.0.tar.gz.
File metadata
- Download URL: aws_json_ips-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7b159922a750fe400033f1c5fbc3e7b8d578c7c7ddfb1c3ca8fa3e1b791e7bf
|
|
| MD5 |
3b77f8eb3e5f921a70022cdcbc424891
|
|
| BLAKE2b-256 |
23e21c5fb8f60afb7d2e668f795403ac4dd0f1a9c71cc84e79eab3becd534c1f
|
File details
Details for the file aws_json_ips-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aws_json_ips-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
899ac6a029aad5b2fa37685d1d3eec11a086e3175ecc615210f0505d77679acb
|
|
| MD5 |
94f658a78042619d43bdfa182c5f0bd6
|
|
| BLAKE2b-256 |
24f44d4d7e9da249cb21227938fb1b8611a48c5535f2ba8d4b7ab4dc1229dcf8
|