Skip to content

Instantly share code, notes, and snippets.

@tgardiner
Created January 13, 2019 02:57
Show Gist options
  • Save tgardiner/aff9bb82830b8345e3cf06ddd2c3c221 to your computer and use it in GitHub Desktop.
Save tgardiner/aff9bb82830b8345e3cf06ddd2c3c221 to your computer and use it in GitHub Desktop.
API Gateway Resource Policy to block Web Crawlers
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:{REGION}:{ACCOUNT_ID}:{API_NAME}/*"
},
{
"Effect": "Deny",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:{REGION}:{ACCOUNT_ID}:{API_NAME}/*",
"Condition": {
"StringEquals": {
"aws:UserAgent": [
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
"Google (+https://developers.google.com/+/web/snippet/)",
"Mozilla/5.0 (compatible; Bingbot/2.0; +http://www.bing.com/bingbot.htm)",
"Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)",
"DuckDuckBot/1.0; (+http://duckduckgo.com/duckduckbot.html)",
"Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)",
"Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)",
"Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)",
"Mozilla/5.0 (compatible; Exabot/3.0; +http://www.exabot.com/go/robot)",
"facebookexternalhit/1.0 (+http://www.facebook.com/externalhit_uatext.php)",
"ia_archiver (+http://www.alexa.com/site/help/webmasters; crawler@alexa.com)"
]
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment