Skip to main content

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_prefix or ipv6_prefix
  • service
  • region
  • network_border_group

The top-level payload also includes:

  • syncToken
  • createDate

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 strings
  • sync_token: source sync token from AWS
  • create_date: source publication date from AWS
  • source_url: JSON URL used
  • selected_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)

Source distribution for aws-json-ips 0.1.0
File Size Uploaded
aws_json_ips-0.1.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws-json-ips 0.1.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page