Skip to content

grantSendMessages of encrypted SQS to Lambda function not generating kms:Decrypt permission #6609

@aherzog-trx

Description

@aherzog-trx

General Issue

We deployed a SQS queue to Account-A that is encrypted with a CMK that resides in Account-B. Permissions of CMK are set to grant allow kms:* to AccountPrincipal('Account-A').
Then we instantiate ourLambda function that is granted write permissions to ourQueue using ourQueue.grantSendMessages(ourLambda).

const sqsKey = Key.fromKeyArn('arn:aws:kms:eu-central-1:0987654321:key/ourKeyId');

const ourQueue = new Queue(this, 'OurQueue', {
    encryption: QueueEncryption.KMS,
    encryptionMasterKey: sqsKey
});

const ourLambda = new Function(this, 'OurLambda', {...});

ourQueue.grantSendMessages(ourLambda);

This results in

"Action": [
    kms:Encrypt",
    kms:ReEncrypt*",
    kms:GenerateDataKey*"
],
"Resource": "arn:aws:kms:eu-central-1:0987654321:key/ourKeyId",
"Effect": "Allow"

being added to ourLambdaExecutionRoleDefaultPolicy.

Lambda function execution failed with KMS AccessDeniedException when sending a message to ourQueue.

After adding

sqsKey.grantDecrypt(ourLambda);

the lambda function executes successfully.

The Question

Is kms:Decrypt strictly necessary to execute sendMessage to an SSE enabled SQS queue? Is this due to the CMK residing in a seperate AWS account?
If so, should kms:Decrypt be added to the Lambda execution role policy when Queue.grantSendMessage(Lambda) is used?

Environment

  • CDK CLI Version: 1.27.0 (build a98c0b3)
  • Module Version: 1.27.0
  • OS: Windows 10
  • Language: TypeScript

Other information

Thanks for the good work!

Metadata

Metadata

Labels

@aws-cdk/aws-sqsRelated to Amazon Simple Queue Serviceeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.guidanceQuestion that needs advice or information.in-progressThis issue is being actively worked on.p1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions