Created
December 5, 2024 21:48
-
-
Save random-robbie/d7ee3f8fe71b28e8a9375ce4176dbbf1 to your computer and use it in GitHub Desktop.
Allows Cloudflare IP's to hit port 443 and 80 on your security group.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Security Group ID | |
SECURITY_GROUP_ID=sg-05e2bcc947b27e64c | |
# Fetch Cloudflare IPv4 and IPv6 ranges | |
IPV4_RANGES=$(curl -s https://www.cloudflare.com/ips-v4/) | |
# Add IPv4 ranges | |
for IP in $IPV4_RANGES; do | |
aws ec2 authorize-security-group-ingress --group-id $SECURITY_GROUP_ID --protocol tcp --port 80 --cidr $IP | |
aws ec2 authorize-security-group-ingress --group-id $SECURITY_GROUP_ID --protocol tcp --port 443 --cidr $IP | |
done | |
echo "Ingress rules for Cloudflare IP ranges added to security group $SECURITY_GROUP_ID." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment