Search code examples
amazon-s3amazon-elastic-beanstalkaws-cliaws-codepipelineaws-codebuild

AWS CodeBuild Error while copying file from S3 - COMMAND_EXECUTION_ERROR: Reason: exit status 1 (NodeJS)


I am getting this error while trying to copy a file from S3 bucket to the build artifacts, post build.

My build phase error logs says: COMMAND_EXECUTION_ERROR: Error while executing command: aws s3 cp "s3://bucket/config.json" "config.json". Reason: exit status 1

Here's my BuildSpec:

version: 0.2

phases:
  install:
    commands:
    - npm install
  build:
    commands:
      - npm run build
  post_build:
    commands:
      - aws s3 cp "s3://bucket/config.json" "config.json"

Solution

  • Based on the comments.

    The issue was cased by CodeBuld role not having permissions to S3. Thus, to solve the issue, needed permissions to S3 were added to the role.