Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
asilverman opened this issue May 23, 2020 · 2 comments
Closed
2 tasks done

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

asilverman opened this issue May 23, 2020 · 2 comments
Assignees

Comments

@asilverman
Copy link

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
Copy link
Contributor

lokst commented Jun 4, 2020

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

@KyleTryon KyleTryon self-assigned this Jun 17, 2020
KyleTryon added a commit that referenced this issue Jun 24, 2020
Address a few known bugs and improve/optimize the config logic, and install logic.

Minor changes:

reconstructed skip-install-check parameter
New bash optimization required re-doing the parameter. Should work essentially the same but with this much change to the logic I did not want to consider this a patch in the case this might affect a user differently. Settling on a minor change, as this shouldn't cause errors.
Bug Fix:

Previously, if you had selected to install AWS CLI v2, but v1 was already installed, the orb would exit without error and skip the install thinking it was already installed.
Orb now checks to see if the installed version matched the config version, if they do not match, the installed version will be replaced.
#47 Fix setting default AWS region
#42 updated tests show success for both versions of CLI on each executor (windows not included)
Other:

Rework install logic
Now checks to see if AWS is already installed, and what version.
Skips if the version installed matches the desired version. If not, the installed version will be replaced automatically.
#45 Provide better error message when attempting to install v1 on a non-python image
Increased and improved testing.
@KyleTryon
Copy link
Contributor

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
#48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants