- Newest
- Most votes
- Most comments
To ensure appropriate permissions for a role that has access to an AWS S3 bucket encrypted with KMS, especially when the role is being assumed from a third-party account, you need to consider several aspects. Let's break this down:
- S3 Bucket Policy:
- You don't necessarily need to add the role to the principal of the bucket policy if the role is in the same account as the bucket. The IAM role permissions should be sufficient.
- However, if you want to be explicit, you can add the role ARN to the bucket policy's principal for added clarity.
- IAM Role Permissions:
- Ensure the role has the necessary S3 permissions (e.g., s3:GetObject, s3:ListBucket).
- The role should also have permissions for KMS actions (e.g., kms:Decrypt).
- KMS Key Policy:
- This is crucial. The KMS key policy must allow the role to use the key for decryption.
- Add a statement in the KMS key policy that allows the role to use the key:
{
"Sid": "Allow use of the key",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::ACCOUNT-ID:role/ROLE-NAME"
},
"Action": [
"kms:Decrypt",
"kms:DescribeKey"
],
"Resource": "*"
}
- Trust Relationship: Since the role is being assumed from a third-party account, you need to ensure the role's trust relationship allows the external account to assume it:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::EXTERNAL-ACCOUNT-ID:root"
},
"Action": "sts:AssumeRole",
"Condition": {}
}
]
}
- External Account Permissions:
The IAM user or role in the external account must have permissions to assume the role in your account.
To answer your specific questions:
-
This is not strictly "cross-account access" for the S3 bucket since the role and bucket are in the same account. However, the process of assuming the role is a cross-account action.
-
You don't necessarily need to add the role to the bucket policy's principal if it's in the same account, but doing so can make the permissions more explicit and easier to audit.
-
The key components are:
- IAM role permissions for S3 and KMS
- KMS key policy allowing the role to use the key
- Correct trust relationship on the role
- Permissions in the external account to assume the role
If all these are in place, the assumed role should be able to access the encrypted S3 bucket. If you're still encountering issues, I'd recommend using AWS CloudTrail to identify any permission-related errors and adjust accordingly.
If everything you're saying is correct and the IAM Policy that the role you assume has attached the right permissions. You should be good on that end.
As what you're looking for is to have a third-party account access your S3 bucket in your account, yes, it would be considered Cross-Account access. As the bucket is in Account A and there would be resources of Account B accesing bucket of Account A.
You just need to make sure to setup the correct Trust Policy as detailed here and that would allow the resources in the Trust Policy to assume that role.
If you need more guidance or you face any issue let us know, happy to help. Setting this kind of access the first time is a little bit weird as there are a lot of terms and moving pieces.
answered 2 years ago
Relevant content
asked 3 years ago
