Skip to content

Instantly share code, notes, and snippets.

@karuna
Created May 25, 2017 02:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karuna/99904116f1c3e5c3dd2801ef2ea154f4 to your computer and use it in GitHub Desktop.
Save karuna/99904116f1c3e5c3dd2801ef2ea154f4 to your computer and use it in GitHub Desktop.
S3 Bucket Policy
{
"Version": "2008-10-17",
"Id": "",
"Statement": [
{
"Sid": "Allow in my domains",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET-NAME/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"http://www.YOUR-WEBSITE.com/*"
]
}
}
},
{
"Sid": "Deny access if referer is not my sites",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET-NAME/*",
"Condition": {
"StringNotLike": {
"aws:Referer": [
"http://www.YOUR-WEBSITE.com/*"
]
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment