CircleCI-Public / aws-cli-orb

Install and configure the AWS command-line interface (awscli)
https://circleci.com/orbs/registry/orb/circleci/aws-cli
MIT License
57 stars 51 forks source link

aws-cli v1 installation fails on docker executor `cimg/base:edge` #45

Closed asilverman closed 4 years ago

asilverman commented 4 years ago

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug Execution of aws-cli/install command of aws version"1" fails when using docker executor image cimg/base:edge

SDK version number circleci/aws-cli@1.0.0

Platform/OS/Hardware/Device docker executor image cimg/base:edge

To Reproduce (observed behavior) Steps to reproduce the behavior Set up a job to use the above docker image that runs the aws-cli/install step, see below

jobs:
  build:
    docker:
      - image: cimg/base:edge
    steps:
      - aws-cli/install:
          version: "1"

Expected behavior The aws-cli tool is installed successfully

Logs/output

#!/bin/bash -eo pipefail
AWS_CLI_VERSION_SELECTED=1
case $AWS_CLI_VERSION_SELECTED in
  "1")
    if [ "false" == "false" ] && which aws > /dev/null; then
        echo "The AWS CLI is already installed. Skipping."
        exit 0
      fi

      export PIP=$(which pip pip3 | head -1)
      if [[ -n $PIP ]]; then
        if which sudo > /dev/null; then
          sudo $PIP install awscli --upgrade
        else
          # This installs the AWS CLI to ~/.local/bin. Make sure that ~/.local/bin is in your $PATH.
          $PIP install awscli --upgrade --user
        fi
      elif [[ $(which unzip curl | wc -l) -eq 2 ]]; then
        cd
        curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
        unzip awscli-bundle.zip
        if which sudo > /dev/null; then
          sudo ~/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
        else
          # This installs the AWS CLI to the default location (~/.local/lib/aws) and create a symbolic link (symlink) at ~/bin/aws. Make sure that ~/bin is in your $PATH.
          awscli-bundle/install -b ~/bin/aws
        fi
        rm -rf awscli-bundle*
        cd -
      else
        echo "Unable to install AWS CLI. Please install pip."
        exit 1
      fi
  ;;
  "2")
    if [ "false" == "false" ] && which aws > /dev/null; then
        echo "The AWS CLI is already installed. Skipping."
        exit 0
      fi

      if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi

      cd /tmp || exit

      # PLATFORM CHECK: mac vs. alpine vs. other linux
      if uname -a | grep Darwin; then
        SYS_ENV_PLATFORM=darwin
      elif uname -a | grep Linux; then
        SYS_ENV_PLATFORM=linux
      else
        echo "This platform appears to be unsupported."
        uname -a
        exit 1
      fi

      case $SYS_ENV_PLATFORM in
        linux)
          curl -sSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
          unzip awscliv2.zip
          $SUDO ./aws/install
          rm awscliv2.zip
          ;;
        darwin)
          curl -sSL "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
          $SUDO installer -pkg AWSCLIV2.pkg -target /
          rm AWSCLIV2.pkg
          ;;
        *)
          echo "This orb does not currently support your platform. If you believe it should, please consider opening an issue on the GitHub repository:"
          echo "https://github.com/CircleCI-Public/aws-cli-orb/issues/new"
          exit 1
      esac

      # Installation check

      if aws --version &> grep -q "aws-cli/2"; then
        echo "AWS CLI V2 has been installed successfully"
        exit 0
      else
        echo "There was an issue installing the AWS CLI V2. Exiting."
        exit 1
      fi
  ;;
  *)
    echo "An incorrect version selection has been made."
    exit 1
  ;;
esac
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15.7M  100 15.7M    0     0  84.9M      0 --:--:-- --:--:-- --:--:-- 84.5M
Archive:  awscli-bundle.zip
  inflating: awscli-bundle/install   
  inflating: awscli-bundle/packages/virtualenv-16.7.8.tar.gz  
  inflating: awscli-bundle/packages/urllib3-1.25.7.tar.gz  
  inflating: awscli-bundle/packages/python-dateutil-2.8.0.tar.gz  
  inflating: awscli-bundle/packages/PyYAML-5.2.tar.gz  
  inflating: awscli-bundle/packages/botocore-1.16.16.tar.gz  
  inflating: awscli-bundle/packages/s3transfer-0.3.3.tar.gz  
  inflating: awscli-bundle/packages/futures-3.3.0.tar.gz  
  inflating: awscli-bundle/packages/docutils-0.15.2.tar.gz  
  inflating: awscli-bundle/packages/colorama-0.4.3.tar.gz  
  inflating: awscli-bundle/packages/awscli-1.18.66.tar.gz  
  inflating: awscli-bundle/packages/rsa-3.4.2.tar.gz  
  inflating: awscli-bundle/packages/six-1.15.0.tar.gz  
  inflating: awscli-bundle/packages/urllib3-1.25.9.tar.gz  
  inflating: awscli-bundle/packages/PyYAML-5.3.1.tar.gz  
  inflating: awscli-bundle/packages/pyasn1-0.4.8.tar.gz  
  inflating: awscli-bundle/packages/jmespath-0.10.0.tar.gz  
  inflating: awscli-bundle/packages/colorama-0.4.1.tar.gz  
  inflating: awscli-bundle/packages/setup/setuptools_scm-3.3.3.tar.gz  
  inflating: awscli-bundle/packages/setup/wheel-0.33.6.tar.gz  
/usr/bin/env: ‘python’: No such file or directory

Exited with code exit status 127
CircleCI received exit code 127

Additional context Add any other context about the problem here.

lokst commented 4 years ago

@asilverman Could you try it on a cimg/python image instead? Version 1 of the AWS cli requires python to be installed.

KyleTryon commented 4 years ago

Hello all,

Improved messaging has been added to the latest edition of our aws cli orb. You will now see a more helpful error if the v1 CLI is attempted on an environment without python installed. Happy building!

https://circleci.com/orbs/registry/orb/circleci/aws-cli @1.2.0 released https://github.com/CircleCI-Public/aws-cli-orb/pull/48