Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanreece/aws-cloudfront-ip-ranges
Python script to fetch the latest IPv4 and IPv6 prefixes from the official AWS IP address ranges list. Alternate method via curl + jq.
https://github.com/ryanreece/aws-cloudfront-ip-ranges
aws cloudfront curl jq
Last synced: about 2 months ago
JSON representation
Python script to fetch the latest IPv4 and IPv6 prefixes from the official AWS IP address ranges list. Alternate method via curl + jq.
- Host: GitHub
- URL: https://github.com/ryanreece/aws-cloudfront-ip-ranges
- Owner: ryanreece
- Created: 2024-02-17T15:26:03.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-01T21:48:39.000Z (10 months ago)
- Last Synced: 2024-03-01T22:39:48.619Z (10 months ago)
- Topics: aws, cloudfront, curl, jq
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AWS CloudFront IP Ranges
A simple Python script for fetching and parsing AWS IP ranges, specifically focusing on CloudFront services. It leverages the AWS `ip-ranges.json` data to extract IPv4 and IPv6 ranges associated with CloudFront, helping users to programmatically access and utilize this information for various purposes such as updating firewall rules, network monitoring, and security configurations
## Features
- Fetch AWS IP ranges from the official AWS `ip-ranges.json` URL.
- Filter and extract CloudFront-related IP ranges (both IPv4 and IPv6).
- Easy to integrate with other Python scripts or projects.## Installation
This project uses Poetry for dependency management. If you do not have Poetry installed, please follow the instructions on the [Poetry website](https://python-poetry.org/docs/#installation) to install it.
```bash
poetry install
```## Running the Script
```bash
poetry run python aws_cloudfront_ip_ranges/aws_cloudfront_ip_ranges.py
```## One liner with curl + jq
If you want a quick and easy way to retrieve the CloudFront or any other service ip address, simply use curl to download the file and then parse the data using `jq`.
### Get IPv4 CloudFront Addresses
```bash
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.service == "CLOUDFRONT") | .ip_prefix'
```### Get IPv6 CloudFront Addresses
```bash
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.ipv6_prefixes[] | select(.service == "CLOUDFRONT") | .ipv6_prefix'
```