Skip to main content

DVA-C02 practice question · Deployment

A developer starts AWS CodeBuild builds directly (not from AWS CodePipeline).

A developer starts AWS CodeBuild builds directly (not from AWS CodePipeline). Each build uploads a ZIP artifact to an Amazon S3 bucket. The artifact name is static, so every build overwrites the previous artifact. The developer wants each artifact name to include the CodeBuild build number. What should the developer do?

  • ASet artifacts/name in the buildspec to a value that uses $CODEBUILD_BUILD_NUMBER, and turn on the project's artifact name override (semantic versioning) setting
  • BList CODEBUILD_BUILD_NUMBER under env/exported-variables in the buildspec so that CodeBuild appends it to the artifact name
  • CSet artifacts/s3-prefix in the buildspec to $CODEBUILD_BUILD_NUMBER and leave the project's artifact namespace type set to NONE
  • DDefine a custom environment variable named CODEBUILD_ARTIFACT_NAME in the buildspec's env/variables block that includes the build number
Show the answer and explanation

Correct answer: A) Set artifacts/name in the buildspec to a value that uses $CODEBUILD_BUILD_NUMBER, and turn on the project's artifact name override (semantic versioning) setting

A buildspec artifacts/name value can use shell syntax and CodeBuild environment variables such as CODEBUILD_BUILD_NUMBER. CodeBuild applies that name only when the project's override artifact name (semantic versioning) setting is enabled.

Why each option is right or wrong

  • A) Correct. The buildspec artifacts/name value is evaluated at build time with shell syntax, so it can include CodeBuild environment variables such as CODEBUILD_BUILD_NUMBER. CodeBuild uses this name only when overrideArtifactName is set on the project (console: Enable semantic versioning).
  • B) Incorrect. exported-variables makes variables available to later stages in CodePipeline. It does not change the name of the artifact that is uploaded to S3.
  • C) Incorrect. s3-prefix applies only when the namespace type is BUILD_ID, and even then it sets a path prefix, not the artifact name. With namespace type NONE, the prefix is not used.
  • D) Incorrect. The CODEBUILD_ prefix is reserved for internal use and must not be used for custom variables. CodeBuild also does not read any such variable to name artifacts.
Exam domain
Deployment · 24% of DVA-C02
Question type
Multiple choice (one answer)

Practise the full DVA-C02 exam

This question is one of a small free sample from the CertRidge DVA-C02 bank. Full practice exams match the real exam's length, time limit and domain weights, explain every option, and Review Mode re-drills the questions you miss.

Original question written from the official exam guide. Not affiliated with AWS; never copied from the real exam.

Worth reading: DVA-C02 cheat sheet, Lambda, DynamoDB, API Gateway, IAM and Cognito, messaging, CI/CD and X-Ray in tables, plus what DVA-C03 changes.