Skip to content

Instantly share code, notes, and snippets.

@Esl1h
Last active April 29, 2019 22:50
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 Esl1h/346176ac380c54274b411924f6a9e8bf to your computer and use it in GitHub Desktop.
Save Esl1h/346176ac380c54274b411924f6a9e8bf to your computer and use it in GitHub Desktop.
AWS S3 bucket policy example - one bucket (public, to a cloudfront distribution) and restrict permissions on some folders by username.
{
"Version": "2012-10-17",
"Id": "Policy1556318075116",
"Statement": [
{
"Sid": "Stmt1556317630862",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::cdn.example/videos/*"
},
{
"Sid": "Stmt1556317630862",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::cdn.example/images/*"
},
{
"Sid": "Stmt1556317630862",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::cdn.example/xml/*",
"arn:aws:s3:::cdn.example/private/*"
],
"Condition": {
"ForAnyValue:StringNotEquals": {
"aws:username": "my-app-user"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment