0

I am trying to set up a pipeline that builds my react application and deploys it to my AWS S3 bucket. It is building fine, but fails on the deploy.

My .gitlab-ci.yml is :

image: node:latest

variables:
  AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
  AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
  S3_BUCKET_NAME: $S3_BUCKET_NAME

stages:
  - build
  - deploy

build:
  stage: build
  script:
    - npm install --progress=false
    - npm run build

deploy:
  stage: deploy
  script:
    - aws s3 cp --recursive ./build s3://MYBUCKETNAME

It is failing with the error:

sh: 1: aws: not found

3 Answers 3

1

The error is telling you AWS CLI is not installed in the CI environment. You probably need to use GitLab’s AWS Docker image. Please read the Cloud deployment documentation.

Sign up to request clarification or add additional context in comments.

Comments

1

@jellycsc is spot on. Otherwise, if you want to just use the node image, then you can try something like Thomas Lackemann details (here), which is to use a shell script to install; python, aws cli, zip and use those tools to do the deployment. You'll need AWS credentials stored as environment variables in your gitlab project. I've successfully used both approaches.

1 Comment

Looks like the Thomas Lackemann link is dead
0

Install "awscli" at the beginning of script.

deploy:
  stage: deploy
  script:
    - apk add --no-cache curl jq python3 py3-pip
    - pip install awscli
    - aws s3 cp --recursive ./build s3://MYBUCKETNAME

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.