A developer creates a customer managed key in AWS KMS to encrypt sensitive configuration payloads. The developer then attaches an IAM policy to an IAM role associated with an Amazon EC2 instance. The IAM policy grants permission for the `kms:Decrypt` action on the key's Amazon Resource Name (ARN). However, when the application running on the EC2 instance attempts to call the Decrypt API, it receives an `AccessDeniedException`. Which of the following is the most likely cause of this authorization failure?
- The key policy for the customer managed key does not contain a statement that delegates permissions to the AWS account, which is required for IAM policies to grant access to the key.Answer
- BThe developer needs to configure a trust policy on the KMS key itself that explicitly lists the IAM role of the EC2 instance as a trusted entity.
- CThe payload being decrypted is stored in Systems Manager Parameter Store as a SecureString parameter, which ignores KMS key policies and relies solely on Parameter Store policies.
- DThe application must perform client-side envelope encryption locally to decrypt the ciphertext, which bypasses the need for the `kms:Decrypt` API call.
Answer
The key policy for the customer managed key does not contain a statement that delegates permissions to the AWS account, which is required for IAM policies to grant access to the key.
For customer managed keys, AWS KMS evaluates both the key policy and the IAM policies. For an IAM policy to successfully grant access, the KMS key policy must contain a statement that delegates permission to the AWS account (specifically referencing the account's root principal ARN). If this delegation is missing, IAM policy permissions on the key are ignored, resulting in an AccessDeniedException.
Step-by-Step Solution
Key Concept
AWS KMS Key Policies and IAM Policy Integration