Skip to content

Instantly share code, notes, and snippets.

@siddolo
Created October 2, 2025 17:53
Show Gist options
  • Save siddolo/536f71c01211c65f7ce9438c46bb57ca to your computer and use it in GitHub Desktop.
Save siddolo/536f71c01211c65f7ce9438c46bb57ca to your computer and use it in GitHub Desktop.
Obtain sorted list of AWS IPs, in CIDR notation, per specific regions and specific services (e.g., EC2, which also includes LAMBDA)
#!/usr/bin/env sh
AWS_REGION=eu-west-1
AWS_SERVICE=EC2
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | \
jq '.prefixes[] | select(.region=="'${AWS_REGION}'" and .service=="'${AWS_SERVICE}'")' | \
jq -r '.ip_prefix' | sort -V -t '/' -k 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment