A SysOps administrator is configuring automatic rotation for a database secret in AWS Secrets Manager. The database is an Amazon RDS PostgreSQL instance running in a private subnet. The secret is encrypted with a customer-managed KMS key. The administrator creates a rotation Lambda function in the same VPC and associates it with the secret. During testing, the rotation fails. CloudWatch Logs for the Lambda function show that `GetSecretValue` calls return a `DecryptionException`. The Lambda function's execution role has an IAM policy attached that allows `kms:Decrypt` and `kms:DescribeKey` on the database secret's KMS key ARN.
Which of the following is the most likely cause of this error?
- AThe Secrets Manager service principal (`secretsmanager.amazonaws.com`) has not been granted permission to assume the Lambda function's execution role in the role's trust policy.
- BThe VPC route table associated with the Lambda function's subnet does not contain a route to the AWS KMS Gateway Endpoint, preventing the decryption request from reaching the service.
- The key policy of the customer-managed KMS key does not grant access to the Lambda execution role and lacks a statement allowing IAM policies to govern access to the key.Cevap
- DThe IAM policy attached to the Lambda execution role lacks the `iam:PassRole` permission for the AWS KMS service role, preventing the key from being passed to the Secrets Manager service.
Cevap
The key policy of the customer-managed KMS key does not grant access to the Lambda execution role and lacks a statement allowing IAM policies to govern access to the key.
The correct answer is correct because AWS KMS requires that the key policy explicitly allow access to the key, or delegate administration to the account's IAM policies (often done by permitting the root principal). If the key policy does not permit the root user or the specific Lambda execution role, any IAM policies granting access to the key will be ignored, resulting in a DecryptionException when Secrets Manager attempts to decrypt the secret using the Lambda execution role.
Adım Adım Çözüm
Anahtar Kavram
AWS KMS Key Policy Precedence and Secrets Manager Rotation