A developer is configuring an AWS Serverless Application Model (SAM) template for a microservice. The microservice includes an `AWS::Serverless::Function` that requires access to a database password. The password must be rotated automatically every 30 days to comply with corporate security standards.
Which approach should the developer use to securely provide the database password to the function through the SAM template?
- AReference the password in the function's environment variables using an AWS Systems Manager Parameter Store SecureString dynamic reference.
- BStore the password in a local configuration file and omit the `Transform: AWS::Serverless-2016-10-31` declaration at the root of the template to prevent SAM from parsing it.
- Reference the password in the function's environment variables using an AWS Secrets Manager dynamic reference.Answer
- DConfigure the function's execution role with an IAM trust policy that allows the database service principal to inject the password during execution.
Answer
Reference the password in the function's environment variables using an AWS Secrets Manager dynamic reference.
The correct approach is to reference the password using an AWS Secrets Manager dynamic reference. AWS Secrets Manager is designed to store sensitive data such as database credentials and supports automated rotation out of the box. By using a dynamic reference in the environment variables of the function, the SAM deployment safely retrieves the value during stack operations.
Step-by-Step Solution
Key Concept
AWS SAM integration with AWS Secrets Manager dynamic references for automated credential management.
Estimated Time:1m 30s