What does the AWS IP Ranges Search & Security Group Generator do?
The AWS IP Ranges Search & Security Group Generator queries Amazon Web Services' official live IP prefix database (ip-ranges.json). It performs instant reverse lookups on IPv4 addresses to verify AWS ownership, filters active CIDR blocks by AWS service (e.g. CLOUDFRONT, EC2, ROUTE53) and region (e.g. us-east-1, eu-west-1), and compiles rules into Terraform HCL, AWS CLI JSON, or Linux iptables commands.
Core Concepts
Understanding AWS IP range allocation and security group automation:
- Service & Regional Prefixes: AWS segregates network ranges by regional infrastructure and service boundaries (such as global CloudFront edge points of presence).
- Reverse IP Lookup: Matches 32-bit IPv4 integers against subnet masks to detect which AWS service and region owns a given IP address.
- Infrastructure-as-Code Automation: Compiles CIDR lists directly into
aws_security_group_ruleTerraform blocks or AWS CLI authorize-security-group-ingress calls with custom ports and protocols.
How to use the tool?
- Enter IP or Query: Type an IPv4 address to check ownership, or enter a service or region filter.
- Filter Options: Select specific AWS services (e.g.
CLOUDFRONT,AMAZON,EC2) or AWS regions. - Generate & Export: Choose your output format (List View, Terraform HCL, AWS CLI, iptables), then click Copy to export your ingress whitelist.
Related Developer Utilities
If you work with cloud networking, AWS security, and infrastructure automation, explore these complementary tools:
- CIDR Subnet Calculator: Calculate subnet masks, usable host ranges, and broadcast addresses.
- cURL to AWS SigV4 Converter: Sign HTTP requests with AWS Signature Version 4 HMAC headers.
- AWS IAM Policy Minifier: Compress IAM JSON policies to resolve 6,144 character quota limits.
- Port & Protocol Lookup: Search TCP/UDP port numbers and standard service protocols.
REST API Integration
Blueutils provides a free REST API endpoint (POST https://blueutils.com/api/aws/aws-ip-ranges) to programmatically filter AWS IP ranges and generate formatted Security Group configurations.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
query |
String | Search term (IPv4 address, service name, or region code). | "54.182.5.5" |
filters |
Object | Filtering criteria object (service, region). |
{"service": "CLOUDFRONT"} |
format |
String | Optional output formatting style (json, terraform, aws-cli, iptables). |
"terraform" |
iacOptions |
Object | Optional parameters for security rules (port, protocol, sgName). |
{"port": 443, "protocol": "tcp"} |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/aws/aws-ip-ranges \
-H "Content-Type: application/json" \
-d '{
"query": "54.182.5.5",
"filters": { "service": "CLOUDFRONT" }
}'Python
import requests
url = "https://blueutils.com/api/aws/aws-ip-ranges"
payload = {
"query": "54.182.5.5",
"filters": {"service": "CLOUDFRONT"}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = """
{
"query": "54.182.5.5",
"filters": {
"service": "CLOUDFRONT"
}
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/aws/aws-ip-ranges"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether the query was successful. | true |
type |
String | Type of lookup executed (ip_lookup or list). |
"ip_lookup" |
prefixes |
Array | List of matching prefix objects containing IP, service, and region. | [{"ip_prefix": "54.182.0.0/16"}] |
outputText |
String | Generated rules script when format parameter is supplied. | "resource \"aws_security_group\" ..." |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"type": "ip_lookup",
"ip": "54.182.5.5",
"prefixes": [
{
"ip_prefix": "54.182.0.0/16",
"region": "global",
"service": "CLOUDFRONT",
"network_border_group": "global"
}
]
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Invalid input: Search IP address or query cannot be empty."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API to query AWS IP ranges?
Integrating the AWS IP Ranges API into automated security auditing, edge firewall synchronization, or CI/CD pipelines provides essential benefits:
- Rapid Script Validation: Automatically synchronizes origin firewall rules whenever AWS updates public CloudFront or Route53 IP addresses.
- Optimized Token Efficiency for AI Agents: The official
ip-ranges.jsonfile is over 4MB in size. Calling the API filters thousands of entries down to the exact matching CIDR list, saving millions of LLM prompt tokens. - Deterministic Accuracy Without Hallucinations: Ensures 100% accurate bitwise IP-to-CIDR range matching directly from official AWS datasets.
Native Usage
How to query AWS IP ranges locally in terminal environments or scripts:
Windows (CMD / PowerShell)
# Query CloudFront IPs from AWS official endpoint in PowerShell
(Invoke-RestMethod -Uri https://ip-ranges.amazonaws.com/ip-ranges.json).prefixes | Where-Object { $_.service -eq 'CLOUDFRONT' } | Select-Object -ExpandProperty ip_prefixLinux / Unix (Bash)
# Query CloudFront IPs using curl and jq in Linux
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.service=="CLOUDFRONT") | .ip_prefix'Python
Using Python urllib and json:
import urllib.request
import json
url = "https://ip-ranges.amazonaws.com/ip-ranges.json"
with urllib.request.urlopen(url) as response:
data = json.loads(response.read().decode())
cloudfront_ips = [p["ip_prefix"] for p in data["prefixes"] if p["service"] == "CLOUDFRONT"]
print(cloudfront_ips[:5])Java
Using Java HttpClient:
import java.net.URI;
import java.net.http.*;
public class AwsIpRangesExample {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ip-ranges.amazonaws.com/ip-ranges.json"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Downloaded AWS IP ranges length: " + response.body().length());
}
}