Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change the AWS CLI from 1 to 2

When checking the AWS PATH with which aws when changing the AWS CLI from 1 to 2

/Users/username/.pyenv/shims/aws

I used to install via pyenv, but I want to remove it and install it according to system 2, but even if I try it according to the official doc, it is not changed to system 2. https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

It did not change to the 2 system even if I typed this command.

I've also tried uninstalling the AWS CLI, but it doesn't work. Does anyone know of any way to do this?

thank you

like image 782
jadejoe Avatar asked Apr 08 '20 10:04

jadejoe


People also ask

How do I change my AWS CLI aws?

To switch between different AWS accounts, set the AWS_profile environment variable at the command line via export AWS_PROFILE=profile_name . Setting the env variable changes the default profile until the end of your shell session or until you set the variable to a different value.

What is the difference between AWS CLI version 1 and 2?

By default, the AWS CLI version 2 returns all timestamp response values in the ISO 8601 format . In AWS CLI version 1, commands returned timestamp values in whatever format was returned by the HTTP API response, which could vary from service to service.

Is AWS CLI version 1 deprecated?

Tag: deprecation Overview On May 30, 2022, the AWS SDK for Python (Boto3 and Botocore) and the AWS Command Line Interface (AWS CLI) v1 will no longer support Python 3.6. This will be the third in a recent series of runtime deprecations which started in 2021.

What is AWS CLI version 2?

AWS CLI v2 provides pre-built binaries for Windows, Linux, and macOS. You no longer need to have Python installed in order to use the AWS CLI. You don't have to worry about compatible Python versions, virtual environments, or conflicting python packages.


2 Answers

I removed my old aws cli from ~/.pyenv/versions/x.x.x/bin/aws, where x.x.x is the current Python version.

Get the current version:

$ pyenv versions
* 3.7.4 

Remove aws cli from current pyenv bin:

$ rm -rf ~/.pyenv/versions/3.7.4/bin/aws*

Try again which aws:

$ which aws 
/usr/local/bin/aws
like image 152
Marcos Godinho Avatar answered Oct 09 '22 04:10

Marcos Godinho


I had the same issue. This is because pyenv linked the shim to very Python version that command has been installed originally with; that's by the way ok to avoid version conflicts. pip3 and awscli v3 uninstall don't take care of that. What you have to do is to:

  1. First, uninstall the old awscli as noted in the AWS documentation (probably you used pip3). Note: remember to edit your bash_profile or zshrc as you may have a $HOME/.local/bin PATH in your config: you want to remove that too

  2. The aws shim will remain in place until you get rid of that Python version (pyenv uninstall 3.7.x) BUT YOU PROBABLY DON'T WANT THAT

  3. Just remove the shim manually rm /Users/username/.pyenv/shims/aws

  4. Install the AWS CLI v2 using the recommended installed and verify everything works correctly

like image 25
A. Ghelardi Avatar answered Oct 09 '22 05:10

A. Ghelardi