A company has an AWS Lambda function that needs to decrypt data using a customer managed KMS key in the same AWS account. A SysOps Administrator has attached an IAM policy to the Lambda execution role that allows the `kms:Decrypt` action on the KMS key. However, when the Lambda function runs, it fails with an `AccessDeniedException` error during the decryption operation. The customer managed KMS key policy contains only the following statement:
{
"Version": "2012-10-17",
"Id": "key-policy-1",
"Statement": [
{
"Sid": "Allow Key Administration",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:role/AdminRole"
},
"Action": [
"kms:Create*",
"kms:Describe*",
"kms:Enable*",
"kms:List*",
"kms:Put*",
"kms:Update*",
"kms:Revoke*",
"kms:Disable*",
"kms:Get*",
"kms:Delete*",
"kms:TagResource",
"kms:UntagResource",
"kms:ScheduleKeyDeletion",
"kms:CancelKeyDeletion"
],
"Resource": "*"
"
}
]
}
Which modification to the configuration will resolve this error?
- Modify the KMS key policy to include a statement that grants the root account principal (`arn:aws:iam::123456789012:root`) permissions for KMS actions, thereby enabling the Lambda execution role's IAM policy to take effect.Answer
- BConfigure the Lambda execution role's IAM trust policy to trust the KMS service principal (`kms.amazonaws.com`) and add `kms:Decrypt` to the role's identity-based policy.
- CModify the IAM policy attached to the Lambda execution role to grant the role explicit permissions to update the key policy of the KMS key.
- DAttach a resource-based policy to the Lambda function that grants the KMS key permission to invoke the function with decryption actions.