A developer is configuring an AWS CodeBuild project that runs inside a private subnet of a VPC to perform integration tests against an internal Amazon RDS database. The build process must retrieve a database password stored as a SecureString parameter in Systems Manager Parameter Store. The developer stores the build commands in a custom file named `build_config.yml` inside a subdirectory named `specs/` in the source repository.
During the initial run, the build fails with an error indicating that the build specification cannot be found.
Which combination of actions will resolve the buildspec finding error and allow the build to retrieve the parameter?
- Update the Buildspec path to `specs/build_config.yml` in the CodeBuild project settings. Additionally, ensure the VPC has either a NAT Gateway or a VPC interface endpoint for Systems Manager configured.Answer
- BMove the `build_config.yml` file to the root of the repository and rename it to `buildspec.yml`. In the CodeBuild project settings, configure the Buildspec path to point to the `specs/` directory. Ensure that the CodeBuild service role has the `ssm:GetParameters` permission.
- CModify the trust policy of the CodeBuild service role to allow the `ssm.amazonaws.com` service principal to assume the role. In the `build_config.yml` file, define a custom `run-as` parameter under the `pre_build` phase pointing to the CodeBuild service role.
- DIn the CodeBuild project settings, change the environment variable type from Parameter Store to Secrets Manager. In the `build_config.yml` file, change the `env.parameter-store` block to `env.secrets-manager` and migrate the credential to AWS Secrets Manager, as Systems Manager Parameter Store is not supported in VPC-enabled builds.
Answer
Update the Buildspec path to `specs/build_config.yml` in the CodeBuild project settings. Additionally, ensure the VPC has either a NAT Gateway or a VPC interface endpoint for Systems Manager configured.
The correct answer resolves the buildspec finding failure by specifying the custom path in the CodeBuild project configuration. It also addresses the connectivity issue by establishing a valid network path from the private VPC subnet to the public Systems Manager API.
Step-by-Step Solution
Key Concept
AWS CodeBuild custom buildspec paths and VPC network access to AWS services
Estimated Time:2m 0s