There are multiple S3 buckets in the aws account. All users are assigned a group policy which gives S3 all access.
But now the requirement is -> there is one S3 bucket which should be limited access to the all users. In this bucket there are folders as per aws user names. A user should only be able to access the objects in the folder having her username. That user should have all permissions in that specific folder and that user should not be able to access the folders having other user's names.
All S3 buckets : bucket1 , bucket2 to bucket10
Specific bucket : bucket3
Objects in the specific bucket : bucket3/report/user={user_name}
ex : bucket3/report/user=user1 ,bucket3/report/user=user2
Requirement :
- user1 have list, put, delete objects inside -> bucket3/report/user=user1
- user1 can not access bucket3/report/user=user2
Following is the policy we have created. This policy is blocking access to all S3 buckets.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowGroupToSeeBucketListInTheConsole",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::*"
]
},
{
"Sid": "AllowRootAndHReportListingOfBucket",
"Action": [
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::bucket3"
],
"Condition": {
"StringEquals": {
"s3:prefix": [
"",
"report/"
],
"s3:delimiter": [
"/"
]
}
}
},
{
"Sid": "DenyListingOfOtherUserFolder",
"Action": [
"s3:*"
],
"Effect": "Deny",
"Resource": [
"arn:aws:s3:::bucket3"
],
"Condition": {
"StringNotLike": {
"s3:prefix": [
"report/user=${aws:username}/*",
"report/user=${aws:username}"
]
}
}
},
]
}
As I'm new to aws I couldn't resolve the issue. How should I update the policy to get the requirement fulfilled?
Thanks in advance