Skip to main content

awsipranges

Work with the AWS IP address ranges in native Python.

License PyPI Code Coverage Build Docs


Amazon Web Services (AWS) publishes its current IP address ranges in JSON format. Python v3 provides an ipaddress module in the standard library that allows you to create, manipulate, and perform operations on IPv4 and IPv6 addresses and networks. Wouldn't it be nice if you could work with the AWS IP address ranges like native Python objects?

Features

  • Work with the AWS IP prefixes as a simple AWSIPPrefixes collection.
  • Quickly check if an IP address, interface, or network is contained in the AWS IP address ranges.
  • Get the AWS IP prefix that contains an IP address, interface, or network.
  • See what services are served from an IP prefix.
  • Filter the AWS IP prefixes by region, network border group, service, and IP prefix version.
  • Use the AWS prefix data in your app or automation scripts in the format required by your infrastructure.
  • Easily validate the TLS certificate presented by the IP ranges server.
  • awsipranges has no third-party dependencies and is compatible with CPython v3.7+.
>>> import awsipranges

>>> aws_ip_ranges = awsipranges.get_ranges(cafile="amazon_root_certificates.pem")

>>> '52.94.5.15' in aws_ip_ranges
True

>>> aws_ip_ranges['52.94.5.15']
AWSIPv4Prefix('52.94.5.0/24', region='eu-west-1', network_border_group='eu-west-1', services=('AMAZON', 'DYNAMODB'))

>>> aws_ip_ranges.filter(services='CODEBUILD')
{'create_date': datetime.datetime(2021, 8, 24, 1, 31, 14, tzinfo=datetime.timezone.utc),
 'ipv4_prefixes': (AWSIPv4Prefix('3.26.127.24/29', region='ap-southeast-2', network_border_group='ap-southeast-2', services=('CODEBUILD',)),
                   AWSIPv4Prefix('3.38.90.8/29', region='ap-northeast-2', network_border_group='ap-northeast-2', services=('CODEBUILD',)),
                   AWSIPv4Prefix('3.68.251.232/29', region='eu-central-1', network_border_group='eu-central-1', services=('CODEBUILD',)),
                   AWSIPv4Prefix('3.98.171.224/29', region='ca-central-1', network_border_group='ca-central-1', services=('CODEBUILD',)),
                   AWSIPv4Prefix('3.101.177.48/29', region='us-west-1', network_border_group='us-west-1', services=('CODEBUILD',)),
                   ...),
 'ipv6_prefixes': (),
 'sync_token': '1629768674'}

>>> for prefix in aws_ip_ranges.filter(regions='eu-west-1', services='DYNAMODB'):
...     print(prefix.network_address, prefix.netmask)
...
52.94.5.0 255.255.255.0
52.94.24.0 255.255.254.0
52.94.26.0 255.255.254.0
52.119.240.0 255.255.248.0

Installation

Installing and upgrading awsipranges is easy:

Install via PIP

❯ pip install awsipranges

Upgrade to the latest version

❯ pip install --upgrade awsipranges

Documentation

Excellent documentation is now available at: https://aws-samples.github.io/awsipranges/

Check out the Quickstart to dive in and begin using awsipranges.

Contribute

See CONTRIBUTING for information on how to contribute to this project.

Security

See CONTRIBUTING for information on how to report a security issue with this project.

License

This project is licensed under the Apache-2.0 License.

Metadata

Release files for awsipranges 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for awsipranges 0.3.3
File Size Uploaded
awsipranges-0.3.3.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for awsipranges 0.3.3
File Interpreter ABI Platform
awsipranges-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 34.8 kB

Release files / awsipranges-0.3.3.tar.gz

Download URL awsipranges-0.3.3.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4f0b3f22a9dc1163c85b513bed812b6c92bdacd674e6a7b68252a3c25b99e2c0
BLAKE2b-256 checksum
How to use checksums
192e6efa95f995369da828715f41705686cd214b9259ed758266942553d40441
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.2 Linux/5.11.0-1028-azure

Release files / awsipranges-0.3.3-py3-none-any.whl

Download URL awsipranges-0.3.3-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3d7a54aeaf7fe310beb5d377a4034a63a51b72677ae6af3e0967bc4de7eedaf
BLAKE2b-256 checksum
How to use checksums
83ce5c9a8bf91bdc9592a409c99e58fd99f2727ab8d634719c0ad796021b76d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.2 Linux/5.11.0-1028-azure

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.1

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

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