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

2

5

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"
Songful answered 23/1, 2021 at 11:1 Comment(4)
Are there any more detail logs? Did you enable CloudWatch Logs for the CB project?Rake
I will enable CloudWatch logs, re-run the build and post the logs in sometime. For now, I was wondering do we even have access to aws cli within the build spec file?Songful
Yes, there is aws cli. One immediate thing that comes to mind, is if the CB role has permissions to access your s3 buckets and objects?Rake
The issue was with the permissions! Thanks a ton, @Marcin. You can post it as the answer.Songful
R
8

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.

Rake answered 23/1, 2021 at 12:31 Comment(0)
T
0

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.

Toad answered 6/2, 2023 at 21:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.