saibbyweb
saibbyweb

Reputation: 3264

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"

Upvotes: 5

Views: 7342

Answers (2)

hallman76
hallman76

Reputation: 81

You can also try adding the --debug flag to your aws cli command to get more information.

In this case:

aws s3 cp --debug "s3://bucket/config.json" "config.json"

This will show you more detail on where things are failing.

Upvotes: 0

Marcin
Marcin

Reputation: 239000

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.

Upvotes: 8

Related Questions