1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

EC2のAWS CLIをver.2にしてみる

Last updated at Posted at 2020-07-11

EC2の AWS CLI が ver.1 だったので ver.2 にしてみる。

##ver.1のアンインストール
公式ドキュメントとおりにやっていく。
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/install-linux.html#install-linux-bundled-uninstall

バージョン確認
$ aws --version
aws-cli/1.16.300 Python/2.7.18 Linux/4.14.181-140.257.amzn2.x86_64 botocore/1.13.36
$
アンインストール
$ sudo rm -rf /usr/local/aws
$
$ sudo rm /usr/local/bin/aws
rm: cannot remove ‘/usr/local/bin/aws’: No such file or directory
$

2つ目のrmは消すものが該当するファイルがなかった。
環境によってパスが違うのかな?と探してみる。

find
$ sudo find /usr -name aws
/usr/bin/aws
$

/usr/local/bin/aws ではなく
/usr/bin/aws にあったので消しておく。

アンインストール
$ sudo rm /usr/bin/aws
$

##ver.2のインストール
公式ドキュメントとおりにやっていく。
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/install-cliv2-linux.html#cliv2-linux-install

インストールファイルのダウンロード
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 31.5M  100 31.5M    0     0  82.8M      0 --:--:-- --:--:-- --:--:-- 82.8M
$
解凍
$ unzip awscliv2.zip
Archive:  awscliv2.zip
   creating: aws/
   creating: aws/dist/
  inflating: aws/README.md
  inflating: aws/install
    ・
    ・
  (中略)
    ・
    ・
  inflating: aws/dist/include/python3.7m/pyconfig.h
   creating: aws/dist/lib/python3.7/
   creating: aws/dist/lib/python3.7/config-3.7m-x86_64-linux-gnu/
  inflating: aws/dist/lib/python3.7/config-3.7m-x86_64-linux-gnu/Makefile
$
インストール
$ sudo ./aws/install
You can now run: /usr/local/bin/aws --version
$
バージョン確認
$ aws --version
aws-cli/2.0.30 Python/3.7.3 Linux/4.14.181-140.257.amzn2.x86_64 botocore/2.0.0dev34
$

最後のバージョン確認で /usr/bin/aws が見つからないといったエラーが過去に1度だけ出たことがあるが、ver.1をアンインストールする前の環境変数でも残っているのかなと思いログインし直したところエラーにならなくなった。今となっては再現しないのでその時ちゃんと調べれば良かった。

##後片付け
不要ファイル(ダウンロードファイル、解凍ファイル)を削除する。

後片付け
$ ls -l
total 32324
drwxr-xr-x 3 ec2-user ec2-user       78 Jul  9 21:44 aws
-rw-rw-r-- 1 ec2-user ec2-user 33095846 Jul 11 08:06 awscliv2.zip
$
$
$ rm -rf aws awscliv2.zip
$
$
$ ls -l
total 0
$
1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?