Here's my scenario:
- There are two aws accounts -
A
andB
. - I have a KMS key
K
protecting an SQS queue in accountA
and regionus-east-1
. - I have an SNS topic in account
B
and regionus-west-2
. - My SQS queue from account
A
is subscribed to the topic from accountB
. - My KMS key's resource policy currently allows the SNS topic to perform encryption/decryption. I am using AWS CDK for my application. Following is the line of code that sets up these permissions:
encryptionMasterKey.addToResourcePolicy(new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ["kms:Create*",
"kms:Describe*",
"kms:Enable*",
"kms:List*",
"kms:Put*",
"kms:Update*",
"kms:Revoke*",
"kms:Disable*",
"kms:Get*",
"kms:Delete*",
"kms:ScheduleKeyDeletion",
"kms:CancelKeyDeletion",
"kms:GenerateDataKey",
"kms:TagResource",
"kms:UntagResource"],
resources: ["*"],
principals: [new iam.AccountPrincipal("<account B id>")]
}));
Now, here are my observations:
- If I leave the SQS queue unencrypted, my SNS topic is able to deliver message to my queue.
- However, if I enable SSE encryption on the queue with KMS key
K
, the SNS topic fails withKMS.AccessDeniedException
.
I need to be able to encrypt my queue for business reasons. How can I allow my SNS topic to access the KMS key?