Skip to content

Instantly share code, notes, and snippets.

@johnsondnz
Forked from dduvnjak/add_cloudflare_ips.sh
Created August 24, 2018 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnsondnz/cf49ff6f2a7dcdc2d9c47c2aca78211c to your computer and use it in GitHub Desktop.
Save johnsondnz/cf49ff6f2a7dcdc2d9c47c2aca78211c to your computer and use it in GitHub Desktop.
Add CloudFlare IP addresses to an EC2 Security Group using awscli
# first we download the list of IP ranges from CloudFlare
wget https://www.cloudflare.com/ips-v4
# iterate over the lines in the downloaded file
# make sure to set `--group-id` and `--port`; more details at http://docs.aws.amazon.com/cli/latest/reference/ec2/authorize-security-group-ingress.html
while read p; do aws ec2 authorize-security-group-ingress --group-id sg-e0000000 --protocol tcp --port 80 --cidr $p; done< ips-v4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment