Question

Difficulty: MediumAWS CodePipeline

A developer is configuring a continuous delivery pipeline in AWS CodePipeline that consists of Source, Build, and Deploy stages. The developer needs to configure the pipeline to use a custom build specification file located in a subdirectory (build/buildspec.yml) of the source repository. Additionally, the developer must pass a dynamically generated container image tag from the Build stage (AWS CodeBuild) to the Deploy stage (AWS CloudFormation). Which two actions must the developer perform to meet these requirements?

  1. Specify the custom buildspec path 'build/buildspec.yml' in the AWS CodeBuild project configuration.Answer
  2. Define a variable namespace in the CodePipeline build action configuration, and reference the output variable in the subsequent deploy stage using the namespace syntax.Answer
  3. C
    Keep the custom buildspec file in the subdirectory without modifying the CodeBuild settings, as CodePipeline recursively searches the source artifact for any buildspec files.
  4. D
    Modify the CodePipeline service role's trust policy to trust the CodeBuild service principal, allowing CodeBuild to directly assume the role and modify the pipeline's environment variables.
  5. E
    Store the custom buildspec file in AWS Secrets Manager and reference the Secrets Manager ARN in the CodePipeline source action configuration parameters.

Answer

To satisfy the requirements, the developer must specify the custom buildspec path in the CodeBuild project settings and use CodePipeline's native variable namespace feature in the build action configuration to reference output variables in the downstream deployment stage.
Specifying the custom buildspec path in the AWS CodeBuild project configuration is necessary because CodeBuild only looks at the root folder by default. Defining a variable namespace in the CodePipeline build action enables downstream stages to access values like an image tag using variable namespace interpolation.

Step-by-Step Solution

1
Set the custom buildspec location in AWS CodeBuild.
The developer updates the CodeBuild project configuration so that it looks for the build specification file at 'build/buildspec.yml'.
By default, CodeBuild expects the buildspec.yml file to be located in the root of the source directory. Specifying the custom path prevents build initialization failures.
2
Export variables from CodeBuild to CodePipeline.
The developer configures the build action in CodePipeline with a namespace, which acts as a container for output variables generated during the build execution.
Assigning a namespace enables downstream deployment actions to consume exported variables using the namespace references.

Key Concept

AWS CodePipeline Variable Namespaces and CodeBuild Configuration
Rate this question