I want to use the relatively new S3 default encryption property to ensure that all objects written to a particular prefix in an S3 bucket are encrypted. In this case, I need to be able to specify a KMS key owned by a different AWS account as the default key. Is this possible? If so:
how do I specify the key (I'm trying Console initially, though Terraform is the ultimate goal), and
is it sufficient to give AWS S3 permission to encrypt with the foreign-owned KMS key? Or does the role uploading the file also need permission?
Yes, this is possible. For the steps below, let's assume that the S3 bucket lives in account A, controlled by you, and the KMS key lives in account B, controlled by your customer, and that the API call to upload objects to S3 is made by an IAM caller specified in account A (that's my understanding from your question, please correct me if I'm wrong). Steps:
Account B:
Key Users
need to include an external AWS account (account A). To do this on the console after creating the key, it suffices to select the key, go to Key Users
, External accounts
section, click Add external account
, paste the 12-digit AWS account ID from account A and save it. The result will be something like arn:aws:iam::ACCOUNT_ID:root
. This gives access to Admins of account A to the key, and they can grant permissions to it for users/roles defined in account A. Take a note on the KMS key ARN, you'll need it on the next step.Account A:
AWS-KMS
, select Custom KMS ARN
, and then paste the ARN from the KMS key created in account B. From what you wrote, this is not exactly what you want, so the next step is:Final step:
If you customer ever wants to "lock down" usage of the data, all they need to do is temporarily disable the key (using the KMS APIs or the AWS console), and/or schedule the key deletion (but this is not possible to be undone).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With