Circleci 2.0 can't find aws

awscli
aws
circle.yml

#1

I’m using circleCI 2.0 and they can’t find aws but their documents clearly say that aws is installed in default

when I use this circle.yml

version: 2
jobs:
  build:
    working_directory: ~/rian
    docker:
        - image: node:boron
    steps:
        - checkout
        - run:
            name: Pre-Dependencies
            command: mkdir ~/rian/artifacts
        - restore_cache:
            keys: 
              - rian-{{ .Branch }}-{{ checksum "yarn.lock" }}
              - rian-{{ .Branch }}
              - rian-master
        - run:
            name: Install Dependencies
            command: yarn install
        - run:
            name: Test
            command: |
              node -v
              yarn run test:ci
        - save_cache:
            key: rian-{{ .Branch }}-{{ checksum "yarn.lock" }}
            paths:
              - "~/.cache/yarn"
        - store_artifacts:
            path: ~/rian/artifacts
            destination: prefix
        - store_test_results:
            path: ~/rian/test-results
        - deploy:
            command: aws s3 sync ~/rian s3://rian-s3-dev/ --delete

following error occurs:

/bin/bash: aws: command not found
Exited with code 127

so if I edit the code this way

    - deploy:
        command: |
          apt-get install awscli
          aws s3 sync ~/rian s3://rian-s3-dev/ --delete

then i get another kind of error:

Reading package lists... Done


Building dependency tree       


Reading state information... Done

E: Unable to locate package awscli
Exited with code 100

Anyone knows how to fix this???


#2

@ceruberu you’re using CircleCI 2.0 but the documentation you linked is for CircleCI 1.0.

You’re using node:boron as your build image. I’m using node:6.10, which is the same image with a different tag. Here’s how I installed awscli:

# install python and awscli
      - run:
          name: Install dependencies
          working_directory: /
          command: |
            apt-get -y -qq update
            apt-get -y -qq install python3.4-dev
            curl -O https://bootstrap.pypa.io/get-pip.py
            python3.4 get-pip.py --user
            pip install awscli --upgrade --user

awscli install docs: http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-linux.html

You could bake these commands, and therefore awscli, into your own public Docker image and start your circle.yml like so:

version: 2
jobs:
  build:
    working_directory: ~/rian
    docker:
        - image: my-awscli-image:1.0

#3

It’s a Python module not an apt package.


#4

I always want to note that the AWS credentials should now be available within the container by default. No need for special env var workarounds anymore.


#5

thanks I solved it by making my own docker image like you said


#6

Can you elaborate on the should as I might be experiencing the “not being available” side of it.


#7

Can you link to that? I’m 99% sure I worded it that way because the full fleet wasn’t completely updated when I said it.

If you’re using sudo or calling a script, you might need to pass it the env vars.


#8

sudo apt-get -y -qq install awscli worked for me on image: circleci/node:7.10.1, fwiw


#9

The alternative is to apt install python-pip python-dev and pip install awscli


#10

Thanks for above solution…however it is still not working for me. I don’t get build failure or any message about faiure to push content into AWS S3…

**********circle.yml **************

deploy:
docker:
- image: my-image
working_directory: ~/san-d steps:
- run:
name: Install dependencies
working_directory: ~/san-di
command: |
apt-get -y -qq update
apt-get -y -qq install python3.4-dev
curl -O https://bootstrap.pypa.io/get-pip.py
python3.4 get-pip.py --user
pip install awscli --upgrade --user

- run:
      name: Deploy to S3 if tests pass and branch is Master
      command: 
        aws s3 sync ~/san-d/app1 s3://meply --delete

workflows:
version: 2
build-deploy:
jobs:
- build-job
- deploy-job:
requires:
- build-job
filters:
branches:
only: master


Any suggestions , corrections to fix the issue ?

Thanks again !


#11

I hit this issue when deploying to AWS lambda functions and pushing files to S3 bucket. Finally solved it and then built a docker image to save time in installing the AWS CLI every time. Here is a link to the image and the repo!


https://hub.docker.com/r/wilson208/circleci-awscli/

Fire a PR in or open an issue if you need anything added to the image and I will get to it when I can.


#12

It would be nice to have such common utilities as aws CLI to be bundled in circleci containers by default.


#13

Yeah wasn’t awscli installed by default in circleci 1.0?

Can’t they put it Back in?


#14

It’s odd when you consider that CircleCI has built-in support for AWS keys & secrets, and v2 images also come bundled with other development packages such as git and curl.

Would definitely encourage people to use the circleci/ brand of images, rather than build-your-own-from-ours.


#15