Reputation: 3438
I'm trying to give a user from another AWS account access to the bucket itv-twitterstg-archive
and I've added the following bucket policy. They say they are getting a permission denied message. Can anyone see any issues with this policy or recommend anything else I can try? (ps, I've changed the name of the bucket for this example). Also should a buckets policy come into effect as soon as you save it?
EDIT** To summarise, I want the user twitterstg-backup from account AWS account 456456615374 to be able to perform these actions:
"s3:GetObject*"
"s3:PutObject"
"s3:PutObjectAcl"
"s3:DeleteObject"
"s3:GetBucketLocation"
"s3:GetBucketAcl"
"s3:ListBucket"
.
{
"Version": "2012-10-17",
"Id": "twitterstg backup policy",
"Statement": [
{
"Sid": "Allow read/write of Objects within archive from specific user",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::456456615374:user/twitterstg-backup"
},
"Action": [
"s3:GetObject*",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::itv-twitterstg-archive/*"
},
{
"Sid": "Allow read/list of archive Bucket from specific user",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::456456615374:user/twitterstg-backup"
},
"Action": [
"s3:GetBucketLocation",
"s3:GetBucketAcl",
"s3:ListBucket"
],
"Resource": "arn:aws:s3:::itv-twitterstg-archive"
}
]
}
Upvotes: 1
Views: 2632
Reputation: 270104
Your policy as listed in the Question is working perfectly fine for me!
Here's what I did:
In Account A:
User-A
)In Account B:
Bucket-B
)Principal
, I inserted the ARN of User-1
Resource
, used the name of my Amazon S3 bucketI then used the credentials from User-A
to list the contents of Bucket-B
:
aws s3 ls s3://bucket-b --profile user-a
I also copied a file to Bucket-B
:
aws s3 cp foo s3://bucket-b --profile user-a
Bottom line: It's working fine. You should investigate why your users are having a problem. You should also try to reproduce their situation (eg by trying it for yourself).
Upvotes: 1
Reputation: 39226
Please note that the principal should be Account-B (i.e. the other account) value.
"Principal": {
"AWS": "arn:aws:iam::456456615374:user/twitterstg-backup"
},
Example:-
"Principal": {
"AWS": "arn:aws:iam::AccountB-ID:root"
},
Second Account:-
Should setup the IAM user with appropriate policy as well.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Example",
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::itv-twitterstg-archive"
]
}
]
}
How to find account id:-
Please follow the below steps to get the account id of Account-B.
Upvotes: 0