Skip to content

Instantly share code, notes, and snippets.

@danneu
Created May 27, 2017 11:36
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 danneu/a974b35e00a6766feef7433d71b87195 to your computer and use it in GitHub Desktop.
Save danneu/a974b35e00a6766feef7433d71b87195 to your computer and use it in GitHub Desktop.
#!/bin/bash
# pip install --upgrade --user awscli
while IFS= read -r line; do
aws ec2 authorize-security-group-ingress \
--group-id sg-fb153885 \
--protocol tcp \
--port 80 \
--cidr "$line"
done < <(curl --silent https://www.cloudflare.com/ips-v4)
while IFS= read -r line; do
aws ec2 authorize-security-group-ingress \
--group-id sg-fb153885 \
--ip-permissions '[{"IpProtocol": "tcp", "FromPort": 80, "ToPort": 80, "Ipv6Ranges": [{"CidrIpv6": "'"$line"'"}]}]'
done < <(curl --silent https://www.cloudflare.com/ips-v6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment