Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Pelirrojo/80761aac61fe75bbeab1c891dab3b7ac to your computer and use it in GitHub Desktop.
Save Pelirrojo/80761aac61fe75bbeab1c891dab3b7ac to your computer and use it in GitHub Desktop.
Phase 2: Enhanced Protection | Add Geographic Restrictions in CloudFront
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween
# https://blog.evereven.tech
# Obtain distribution ID
aws cloudfront list-distributions --query 'DistributionList.Items[*].Id' --output json
> [
> "E1PI*******PNY"
> ]
# Obtain codes from: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
cat > config.json << 'EOL'
{
"Restrictions": {
"GeoRestriction": {
"RestrictionType": "blacklist",
"Locations": ["XX", "YY", "ZZ"]
}
}
}
EOL
# Overload cloudfront configuracion (replace [YOUR_DISTRIBUTION_ID] with the distribution id)
aws cloudfront update-distribution --id [YOUR_DISTRIBUTION_ID] --distribution-config file://config.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment