A company's CI/CD pipeline uses AWS CodeBuild to compile a web application. The build process requires the main application source code from a primary AWS CodeCommit repository, as well as a common stylesheet template from a secondary AWS CodeCommit repository. The developer configures the CodeBuild project with multiple input sources, setting the secondary source identifier to CommonStyles. During the build, the buildspec must copy the stylesheet from the secondary source directory to the main application's public assets folder. How should the developer reference the file path of the secondary source inside the buildspec.yml file to perform this copy operation?
- Reference the directory path using the `$CODEBUILD_SRC_DIR_CommonStyles` environment variable.Answer
- BReference the directory path using a relative path from the primary source directory, such as `../CommonStyles`.
- CReference the directory path as a subdirectory of the primary working directory, such as `$CODEBUILD_SRC_DIR/CommonStyles`.
- DStore the repository URL in AWS Systems Manager Parameter Store and resolve it using the `parameters` section of the buildspec.
Answer
Reference the directory path using the `$CODEBUILD_SRC_DIR_CommonStyles` environment variable.
When configured with multiple input sources, AWS CodeBuild downloads the primary source to the default build directory referenced by ` CODEBUILD_SRC_DIR_source_identifier` where `source_identifier` is the unique identifier specified in the project configuration. Therefore, referencing `$CODEBUILD_SRC_DIR_CommonStyles` provides the correct path to the secondary source repository's files.
Step-by-Step Solution
Key Concept
AWS CodeBuild Multiple Source Inputs