AWS Developer DVA-C02 · Deployment · medium

A developer is writing a buildspec.yml file for AWS CodeBuild that compiles a Node.js TypeScript service, runs unit tests, and packages a production artifact. During the build, the script needs to fetch a database test password from AWS Secrets Manager (arn:aws:secretsmanager:us-east-1:111122223333:secret:TestDB-AbCdEf) and expose it as an environment variable inside the build container without hardcoding the secret in buildspec.yml. Which native buildspec.yml section supports this?

Published · Last updated · checked before publication — how we verify questions

Options

  • ACommit the plaintext password inside the phases.install.commands list in Git
  • BPlace the secret ARN inside the artifacts.discard-paths boolean field
  • CDeclare the secret under the env: secrets-manager: block in buildspec.ymlCorrect answer
  • DDeclare the secret inside an EC2 appspec.yml ValidateService lifecycle hook

Answer: C. Declare the secret under the env: secrets-manager: block in buildspec.yml

In CodeBuild buildspec.yml (version 0.2), the env.secrets-manager (and env.parameter-store) mapping block natively resolves secrets from AWS Secrets Manager (or SSM Parameter Store) using the CodeBuild service role and injects them as masked environment variables during the build.

Why the other options are wrong

  • A. Commit the plaintext password inside the phases.install.commands list in Git — Committing plaintext secrets into buildspec.yml in Git exposes credentials to anyone with repo access.
  • B. Place the secret ARN inside the artifacts.discard-paths boolean field — discard-paths strips directory hierarchies from output artifacts; it does not resolve Secrets Manager values.
  • D. Declare the secret inside an EC2 appspec.yml ValidateService lifecycle hook — appspec.yml is for AWS CodeDeploy runtime deployment, not AWS CodeBuild compilation.

All Deployment questions and the topic overview →

AWS and Amazon Web Services are trademarks of Amazon.com, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Amazon Web Services.