Soru

Zorluk: OrtaAWS CodeBuild

A developer is setting up an AWS CodeBuild project to build a containerized application. The build process needs to retrieve a database password securely from AWS Secrets Manager. The developer has stored a custom build specification file at the path `build/pipelines/buildspec-dev.yml` in the source repository. During the initial build run, CodeBuild fails immediately because it cannot locate the build specification, and the database credentials are not resolved. Which two actions should the developer take to configure the project correctly? (Choose two.)

  1. Update the CodeBuild project configuration to set the buildspec file path to build/pipelines/buildspec-dev.ymlCevap
  2. In the buildspec-dev.yml file, retrieve the database password by defining it under the secrets-manager key in the env sectionCevap
  3. C
    In the buildspec-dev.yml file, retrieve the database password by defining it under the parameter-store key in the env section
  4. D
    Modify the IAM trust policy of the CodeBuild service role to allow the Systems Manager service (ssm.amazonaws.com) to assume the role
  5. E
    Add a shell command in the install phase of the buildspec file to copy the buildspec-dev.yml file to the root of the source directory

Cevap

To configure the project correctly, the developer must update the CodeBuild project settings to set the buildspec path to the custom subdirectory path, and update the buildspec-dev.yml file to declare the secret under the secrets-manager key in the env section.
To resolve the buildspec locator issue, the developer must explicitly configure the custom file path in the CodeBuild project configuration since it is not named buildspec.yml at the root. To retrieve the secret correctly, the developer must define it under the secrets-manager key in the env block, which instructs CodeBuild to retrieve the value from Secrets Manager natively.

Adım Adım Çözüm

1
Configure the CodeBuild project settings to point to the correct buildspec location.
CodeBuild is successfully able to locate and parse the buildspec file from build/pipelines/buildspec-dev.yml instead of failing at the start of the build.
By default, CodeBuild only searches for buildspec.yml at the root directory of the source provider. Any other name or path must be configured in the project settings.
2
Configure the env section of the buildspec-dev.yml file to pull the database password from Secrets Manager.
The database password is dynamically retrieved and exposed as an environment variable in the build environment.
Using the native secrets-manager key in the env block tells CodeBuild to fetch the secret from AWS Secrets Manager using the service role's permissions.

Anahtar Kavram

AWS CodeBuild buildspec configuration and Secrets Manager integration
Bu soruyu puanla