Skip to content

Instantly share code, notes, and snippets.

@devhops
Created March 24, 2022 17:34
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 devhops/74bd4269ed56d7acfd66bfccc9d4f1bb to your computer and use it in GitHub Desktop.
Save devhops/74bd4269ed56d7acfd66bfccc9d4f1bb to your computer and use it in GitHub Desktop.
Allow access to one subfolder in a bucket, but not to list all buckets or the contents of the root folder
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAccess",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucketMultipartUploads",
"s3:AbortMultipartUpload",
"s3:ListBucket",
"s3:DeleteObject",
"s3:GetObjectVersion",
"s3:ListMultipartUploadParts"
],
"Resource": [
"arn:aws:s3:::BucketName",
"arn:aws:s3:::BucketName/FolderName/*"
]
},
{
"Sid": "DenyAccess",
"Effect": "Deny",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::BucketName",
"Condition": {
"ForAllValues:StringNotEquals": {
"s3:prefix": [
"FolderName",
"FolderName/",
"FolderName/*"
]
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment