LoginSignup
4
2

More than 3 years have passed since last update.

AWS CLI v2 がGAになったのでをアップグレードしました。

Posted at

はじめに

aws-cliのv2がGAになりました。

AWS CLI v2 is now generally available

ということで早速アップグレードしてみたいと思います。

アップグレード

まずは現在のaws-cliのバージョンを確認します。

バージョン確認
$ aws --version
aws-cli/1.16.183 Python/3.6.2 Darwin/19.3.0 botocore/1.12.173

それではインストールです。

パッケージダウンロード
$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.9M  100 19.9M    0     0  5939k      0  0:00:03  0:00:03 --:--:-- 5939k
インストール
$ sudo installer -pkg AWSCLIV2.pkg -target /
Password:
installer: Package name is AWS Command Line Interface
installer: Installing at base path /
installer: The install was successful.

インストールができたのでバージョンを確認します。

バージョン確認
$ aws --version
aws-cli/1.16.183 Python/3.6.2 Darwin/19.3.0 botocore/1.12.173

あれ?なぜかアップグレードできてないです。。。
とりあえずパスを確認してみます。

パス確認
$ which aws
/Users/hoge/.pyenv/shims/aws

今回のインストール先は/usr/local/bin/awsになるはず。。。

バージョン確認
$ /usr/local/bin/aws --version
aws-cli/2.0.0 Python/3.7.4 Darwin/19.3.0 botocore/2.0.0dev4

直接指定して確認するとやはりv2がインストールされています。
原因は.bash_profileでした。

確認
$ grep aws ~/.bash_profile
complete -C '/Users/hoge/.pyenv/shims/aws_completer' aws

これを以下のように書き換えます。

修正
$ grep aws ~/.bash_profile
complete -C '/usr/local/bin/aws_completer' aws

修正したら改めて読み込みます。

読み込み
$ source .bash_profile

改めてパス確認です。

パス確認
$ which aws
/usr/local/bin/aws

パスが修正されたので改めてバージョンの確認をします。

バージョン確認
$ aws --version
aws-cli/2.0.0 Python/3.7.4 Darwin/19.3.0 botocore/2.0.0dev4

ということで無事アップグレード完了です。

おわりに

今回、v1をpyenvで設定し、かつaws_completerも設定していたのを忘れていため、.bash_profileになかなか気づけずアップグレードするのに時間がかかってしまいました。


[参考URL]
・Installing the AWS CLI version 2 on macOS
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/install-cliv2-mac.html
・AWS Command Line Interface - コマンド補完
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/cli-configure-completion.html

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2