A company's security policy requires automatic rotation of database credentials stored in AWS Secrets Manager. A SysOps administrator writes a custom AWS Lambda function to perform the rotation logic. When trying to enable rotation for the database secret, the AWS Management Console displays an error indicating that the Secrets Manager service does not have permission to execute the rotation Lambda function. How should the administrator resolve this error to successfully enable rotation?
- AAssign an IAM policy to the Lambda execution role that grants permission to perform the secretsmanager:RotateSecret action
- Add a permission statement to the Lambda function's policy to allow the secretsmanager.amazonaws.com principal to invoke the functionAnswer
- CUpdate the key policy of the custom KMS key encrypting the secret to permit the Lambda function to perform kms:Decrypt operations
- DConfigure the SysOps administrator's IAM policy to include the iam:PassRole permission for the Lambda function's execution role
Answer
Add a permission statement to the Lambda function's policy to allow the secretsmanager.amazonaws.com principal to invoke the function
AWS Secrets Manager requires permission to invoke the AWS Lambda rotation function. This service-to-service invocation permission must be granted via a resource-based policy on the Lambda function itself, specifying secretsmanager.amazonaws.com as the principal and lambda:InvokeFunction as the action.
Step-by-Step Solution
Key Concept
Resource-based policies for AWS Lambda rotation functions in AWS Secrets Manager
Estimated Time:1m 30s