mspahr
mspahr

Reputation: 153

Gitlab CI failing cannot find aws command

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

Upvotes: 0

Views: 6105

Answers (3)

Franck CHARLES
Franck CHARLES

Reputation: 201

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

Upvotes: 0

Andrew Miller
Andrew Miller

Reputation: 11

@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.

Upvotes: 1

jellycsc
jellycsc

Reputation: 12359

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.

Upvotes: 1

Related Questions