I want an AWS role to have access to two S3 buckets, one in its own account (Account A), and now in another account (Account B). The role currently has access to its own Account S3 bucket.
To have access to the other account S3 bucket, the doc says to update the bucket policy of Account B S3 bucket. This is the current bucket policy
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowSSLRequestsOnly",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::s3bucketB-574e6ce",
"arn:aws:s3:::s3bucketB-574e6ce/*"
],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
}
]
}
I believe I need to add a new statement to the existing. This is the updated policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowSSLRequestsOnly",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::s3bucketB-574e6ce",
"arn:aws:s3:::s3bucketB-574e6ce/*"
],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::1111:role/AccountA-role"
},
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::s3bucketB-574e6ce",
"arn:aws:s3:::s3bucketB-574e6ce/*"
]
}
]
}
The last time I updated an S3 bucket policy, I messed up the bucket and had a tough time reverting it, since I was not able to access it myself. It will be great if someone from the community can review the above-updated policy and let me know if I am on the right track.