A developer is configuring a build project in AWS CodeBuild to package an application. The build process requires retrieving a non-sensitive database port number that rarely changes, and a database password that must be automatically rotated every 30 days. To optimize for cost, operational efficiency, and security, which configuration should the developer implement?
- Store the database port in AWS Systems Manager Parameter Store and the database password in AWS Secrets Manager, and retrieve them using the parameter-store and secrets-manager blocks under the env section of the buildspec.yml file.Answer
- BStore both the database port and the database password in AWS Secrets Manager, and retrieve them using the secrets-manager block under the env section of the buildspec.yml file.
- CStore both the database port and the database password in AWS Systems Manager Parameter Store, and retrieve them using the parameter-store block under the env section of the buildspec.yml file.
- DStore the database port in AWS Systems Manager Parameter Store and the database password in AWS Secrets Manager, and add the required read permissions to the trust relationship policy document of the AWS CodeBuild service role.
Answer
Store the database port in AWS Systems Manager Parameter Store and the database password in AWS Secrets Manager, and retrieve them using the parameter-store and secrets-manager blocks under the env section of the buildspec.yml file.
Storing the port in Parameter Store is cost-effective because standard parameters are free. Storing the password in Secrets Manager meets the security requirement for automatic rotation. Referencing them in the parameter-store and secrets-manager blocks of the env section in the root buildspec.yml file allows CodeBuild to automatically fetch the values and inject them as environment variables during the build execution.
Step-by-Step Solution
Key Concept
Retrieving configuration data and secrets in AWS CodeBuild using AWS Systems Manager Parameter Store and AWS Secrets Manager
Estimated Time:1m 30s