A software engineering team is using AWS CloudFormation to deploy a three-tier web application. The application requires a database password that must be rotated automatically every 30 days. Which approach should the developer use to securely reference the database password in the CloudFormation template?
- ARetrieve the password using a dynamic reference to an AWS Systems Manager Parameter Store SecureString parameter.
- BDefine the database password in a template Parameter with the NoEcho property set to true, and manually update the EC2 instance database configurations out-of-band when the password rotates.
- Retrieve the password using a dynamic reference to AWS Secrets Manager directly within the resource properties in the template.Answer
- DDefine the database password as a standard parameter, and if a stack update fails during rotation, manually delete the database instance to force the stack to continue rollback.
Answer
Retrieve the password using a dynamic reference to AWS Secrets Manager directly within the resource properties in the template.
Using a dynamic reference to AWS Secrets Manager is the recommended best practice for referencing sensitive data that changes dynamically, such as database credentials that rotate every 30 days. AWS Secrets Manager natively integrates with AWS Lambda to rotate credentials automatically and integrates with CloudFormation templates via dynamic references, preventing plaintext passwords from appearing in the template or stack configuration.
Step-by-Step Solution
Key Concept
Using AWS Secrets Manager dynamic references in AWS CloudFormation to secure and automatically rotate database credentials without introducing stack drift.