A developer is configuring an AWS Lambda function to process events from an Amazon SQS queue. The queue is encrypted using an AWS Key Management Service (AWS KMS) customer managed key. The Lambda function's execution role has the following IAM policy attached:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:ReceiveMessage",
"sqs:DeleteMessage",
"sqs:GetQueueAttributes"
],
"Resource": "arn:aws:sqs:us-east-1:123456789012:QueueA"
}
]
}
The KMS customer managed key has the following key policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Allow administration of the key",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:user/KeyManager"
},
"Action": "kms:*",
"Resource": "*"
}
]
}
When the Lambda event source mapping attempts to poll the queue, the function is not triggered, and CloudWatch logs indicate that the Lambda service is unauthorized to decrypt the SQS messages.
Which of the following modifications is required to resolve this authorization failure?
- AModify the trust policy of the AWS KMS key to list the Lambda service principal lambda.amazonaws.com as a trusted entity allowed to assume the KMS key.
- Add kms:Decrypt permissions targeting the KMS key to the Lambda execution role's policy, and update the KMS key policy to allow the Lambda execution role to perform kms:Decrypt operations.Cevap
- CInitialize the AWS SDK client inside the Lambda function by hardcoding the AWS access credentials of the KeyManager IAM user to decrypt the SQS message payload.
- DConfigure an Amazon Cognito Identity Pool to authenticate the Lambda function, and attach a policy allowing the Cognito authenticated role to perform kms:Decrypt on the KMS key.