Skip to content

How to achieve appropriate permissions for a role that has access to the AWS s3 bucket that's encrypted with KMS?

0

I have a role that is assumed in my account and it has access rights for the S3 bucket within the same account, it also appears to hae the policy/permissions for the KMS key actions to encrypt or decrypt necessary data (read only) to the S3 bucket.

My question is there anything else I need to do to make sure this role that's being assumed from a third party account has access to the S3 bucket. The role is located in the same account as the bucket, so I'm not sure if this would fall under the category of "cross account access" since it's the role is in the same account itself; however, the account assuming the role itself is another account and located in another organization.

Do I also need to add the role being assumed in the principal of the bucket policy to get this to work? Or should all the permissions needed be appropriate?

2 Answers
0

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:

  1. 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.
  1. 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).
  1. 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": "*"
}
  1. 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": {}
    }
  ]
}
  1. 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:

  1. 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.

  2. 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.

  3. 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.

AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

0

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

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.