Nimish Bansal
Nimish Bansal

Reputation: 1759

Getting error in phase:DOWNLOAD_SOURCE Failed of secret manager cant find keys

I have this buildspec.yaml for my dotnet project.

version: 0.2
env:
  variables:
    DOTNET_ROOT: /root/.dotnet
  secrets-manager:
    AWS_ACCESS_KEY_ID_PARAM: CodeBuild:AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY_PARAM: CodeBuild:AWS_SECRET_ACCESS_KEY
phases:
  install:
    runtime-versions:
      dotnet: 3.1
  pre_build:
    commands:
      - echo Command ran in Prebuild
      - echo Restore started on `date`
      - export PATH="$PATH:/root/.dotnet/tools"
      - pip install --upgrade awscli
      - aws configure set profile $Profile
      - aws configure set region $Region
      - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID_PARAM
      - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY_PARAM
      - cd Dotnetlambda4
      - cd src
      - cd Dotnetlambda4
      - dotnet clean
      - dotnet restore
  build:
    commands:
      - echo Build started on `date`
      - dotnet new -i Amazon.Lambda.Templates::*
      - dotnet tool install -g Amazon.Lambda.Tools
      - dotnet tool update -g Amazon.Lambda.Tools
      - dotnet lambda deploy-function "Dotnetlambda4" --function-role "arn:aws:iam::433377406395:role/LambdaExecutionRole" --region "us-east-1"
      - echo Build finished.

These are the logs that buil[Container] 2020/10/05 09:44:36 Waiting for agent ping [Container] 2020/10/05 09:44:38 Waiting for DOWNLOAD_SOURCE [Container] 2020/10/05 09:44:39 Phase is DOWNLOAD_SOURCE [Container] 2020/10/05 09:44:39 CODEBUILD_SRC_DIR=/codebuild/output/src073255159/src [Container] 2020/10/05 09:44:39 YAML location is /codebuild/output/src073255159/src/buildspec.yaml [Container] 2020/10/05 09:44:39 No commands found for phase name: install [Container] 2020/10/05 09:44:39 Processing environment variables

First error I think is "No commands found for phase name: install". I don't have any idea from where it is coming

Second in the build phase details I am getting error of secret manager cant find the specified secret.

Below is a screenshot

Phase Details

What should I do?, every time I commit this build is failed with these two errors.

Upvotes: 1

Views: 1391

Answers (1)

Marcin
Marcin

Reputation: 238687

Based on the comments.

"No commands found for phase name: install" is not an error. It is an information message that install phase has no commands.

The issue was due to missing/wrong secret manager secrets. To verify the correct settings have to go to Secret Manger console, them under Secret Name it should write CodeBuild. Next if you Retrieve the secret value, the Secret Key should be AWS_ACCESS_KEY_ID. Same for AWS_SECRET_ACCESS_KEY.

Upvotes: 1

Related Questions