Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need an Amazon S3 user with full access to a single bucket

I have a user foo with the following privileges (it's not a member of any group):

{   "Statement": [     {       "Sid": "Stmt1308813201865",       "Action": "s3:*",       "Effect": "Allow",       "Resource": "arn:aws:s3:::bar"     }   ] } 

That user however seem unable to upload or do much of anything until I grant full access to authenticated users (which might apply to anyone). This still doesn't let the user change permission as boto is throwing an error after an upload when it tries to do do key.set_acl('public-read').

Ideally this user would have full access to the bar bucket and nothing else, what am I doing wrong?

like image 763
Kit Sunde Avatar asked Nov 20 '11 18:11

Kit Sunde


People also ask

How do I give access to a single S3 bucket?

Select the group that you just created, e.g. S3OneFS , and click “Group Actions”. Select “Add Users to Group”. Then, select your user, e.g. ObjectiveFS , and click “Add Users”. You can now use your “Access Key ID” and “Secret Access Key” to run ObjectiveFS restricted to a single bucket.

How do I restrict Amazon S3 bucket access to a specific IAM user?

You can use the NotPrincipal element of an IAM or S3 bucket policy to limit resource access to a specific set of users. This element allows you to block all users who are not defined in its value array, even if they have an Allow in their own IAM user policies.

Who has access to S3 bucket?

By default, all Amazon S3 buckets and objects are private. Only the resource owner which is the AWS account that created the bucket can access that bucket. The resource owner can, however, choose to grant access permissions to other resources and users.


2 Answers

You need to grant s3:ListBucket permission to the bucket itself. Try the policy below.

{   "Statement": [     {       "Effect": "Allow",       "Action": "S3:*",       "Resource": "arn:aws:s3:::bar/*",       "Condition": {}     },     {       "Effect": "Allow",       "Action": [         "s3:ListBucket"       ],       "Resource": "arn:aws:s3:::bar",       "Condition": {}     }   ] } 
like image 188
cloudberryman Avatar answered Oct 21 '22 23:10

cloudberryman


The selected answer didn't work for me, but this one did:

{   "Statement": [     {       "Action": "s3:*",       "Effect": "Allow",       "Resource": [         "arn:aws:s3:::my-bucket",         "arn:aws:s3:::my-bucket/*"       ]     }   ],   "Statement": [     {       "Effect": "Allow",       "Action": "s3:ListAllMyBuckets",       "Resource": "arn:aws:s3:::*"     }   ] } 

Credit: http://mikeferrier.com/2011/10/27/granting-access-to-a-single-s3-bucket-using-amazon-iam/

like image 40
Suman Avatar answered Oct 21 '22 22:10

Suman