An application runs on an Amazon EC2 instance that retrieves its database credentials at startup from AWS Systems Manager Parameter Store. The credentials are encrypted as a SecureString parameter using a custom AWS KMS customer managed key. Although the instance's IAM role has a policy allowing both ssm:GetParameter and kms:Decrypt actions, the application logs show an AccessDeniedException when trying to retrieve the parameter. Which of the following is the most likely cause of this issue?
- The KMS key policy associated with the custom key does not grant the EC2 instance's IAM role permission to perform the kms:Decrypt action.Answer
- BThe EC2 instance's IAM role is missing the iam:PassRole permission to delegate authority to the Systems Manager service.
- CThe automatic rotation configuration for the parameter has failed because the AWS Lambda rotation function failed to update the parameter's rotation metadata.
- DThe EC2 instance is located in a public subnet, but the subnet's route table is missing a route pointing to the Internet Gateway to access the AWS KMS endpoint.
Answer
The KMS key policy associated with the custom key does not grant the EC2 instance's IAM role permission to perform the kms:Decrypt action.
For custom AWS KMS keys, access is evaluated by examining both the caller's IAM policies and the KMS key policy. Even if the EC2 instance role has an IAM policy allowing the decrypt operation, the request will be denied if the key policy does not explicitly permit the role or delegate permissions to the account.
Step-by-Step Solution
Key Concept
KMS key policy permissions and precedence when decrypting secure parameters
Estimated Time:1m 30s