I have the following bucket structure
--- MyBucket.Secure
------Database
---------App1
---------App2
I need to update my IAM role to only allow get/list on MyBucket.Secure/Database/App1.
My situation is similar to the AWS docs on restricting a user folder: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_examples.html#iam-policy-example-s3-home-directory
Having read the guide I came up with the following policy to try and meet the restriction I require:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1408970346000",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::*"
]
},
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::MyBucket.Secure",
"Condition": {"StringLike": {"s3:prefix": [
"",
"Database/",
"Database/App1/*"
]}}
},
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": [
"arn:aws:s3:::MyBucket.Secure/Database/App1",
"arn:aws:s3:::MyBucket.Secure/Database/App1/*"
]
}
]
}
When I use the above policy though I get the following error: A client error (403) occurred when calling the HeadObject operation: Forbidden
Any ideas what else I should change to get this going?