Skip to content

Instantly share code, notes, and snippets.

@tonyfraser
Created June 21, 2019 15:56
Show Gist options
  • Save tonyfraser/d57c158fc2614018909899e5e0255632 to your computer and use it in GitHub Desktop.
Save tonyfraser/d57c158fc2614018909899e5e0255632 to your computer and use it in GitHub Desktop.
a full access policy, designed to assign a subdirectory/subkey to a policy. Think s3://bucket/environmet/dev, only assigning dev to this policy.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::*"
]
},
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::{bucket}",
"Condition": {
"StringLike": {
"s3:prefix": [
"",
"{key}",
"{key}/*",
"{key}/{subkey}",
"{key}/{subkey}/*"
]
}
}
},
{
"Action": [
"s3:*"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::{bucket}/{key}/{subkey}",
"arn:aws:s3:::{bucket}/{key}/{subkey}/*"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment