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?
- Specify the custom buildspec path 'build/buildspec.yml' in the AWS CodeBuild project configuration.Answer
- 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
- CKeep the custom buildspec file in the subdirectory without modifying the CodeBuild settings, as CodePipeline recursively searches the source artifact for any buildspec files.
- DModify 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.
- EStore 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
Key Concept
AWS CodePipeline Variable Namespaces and CodeBuild Configuration