Windows/Linux

AmazonLinux2において、aws cliのバージョンを1から2へ変更する方法について

この記事は投稿日から2年以上経過しています。

当記事では、AmazonLinux2において、aws cliのバージョンを1から2へ変更する方法について記載します。

前提

変更方法について

  • 用意したAmazonLinux 2にて現在のaws cliのバージョン及びOSバージョンを確認します。
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ aws --version
aws-cli/1.18.147 Python/2.7.18 Linux/4.14.243-185.433.amzn2.x86_64 botocore/1.18.6s
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
[ec2-user@ip-172-16-12-244 ~]$
  • シェルのプロファイルを確認します。
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ echo $SHELL
/bin/bash
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$
  • プロファイルに以下のエクスポートコマンドを追記します。
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export PATH=$HOME/.local/bin:$PATH   ###追記箇所###
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$
  • 現在のセッションにて追記したプロファイルを読み込みます。
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ source ~/.bash_profile
/bin/bash
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$
  • aws cliバージョン1を最新バージョンに更新します。
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ pip3 install --upgrade --user awscli
Collecting awscli
  Downloading awscli-1.20.54-py3-none-any.whl (3.7 MB)
     |????????????????????????????????| 3.7 MB 22.4 MB/s
Collecting rsa<4.8,>=3.1.2
  Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
Requirement already satisfied, skipping upgrade: docutils<0.16,>=0.10 in /usr/lib/python3.7/site-packages (from awscli) (0.14)
Collecting s3transfer<0.6.0,>=0.5.0
  Downloading s3transfer-0.5.0-py3-none-any.whl (79 kB)
     |????????????????????????????????| 79 kB 11.7 MB/s
Collecting colorama<0.4.4,>=0.2.5
  Downloading colorama-0.4.3-py2.py3-none-any.whl (15 kB)
Collecting botocore==1.21.54
  Downloading botocore-1.21.54-py3-none-any.whl (8.0 MB)
     |????????????????????????????????| 8.0 MB 33.1 MB/s
Collecting PyYAML<5.5,>=3.10
  Downloading PyYAML-5.4.1-cp37-cp37m-manylinux1_x86_64.whl (636 kB)
     |????????????????????????????????| 636 kB 34.3 MB/s
Collecting pyasn1>=0.1.3
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |????????????????????????????????| 77 kB 11.4 MB/s
Collecting python-dateutil<3.0.0,>=2.1
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |????????????????????????????????| 247 kB 38.5 MB/s
Collecting jmespath<1.0.0,>=0.7.1
  Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
Collecting urllib3<1.27,>=1.25.4
  Downloading urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
     |????????????????????????????????| 138 kB 39.9 MB/s
Collecting six>=1.5
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: pyasn1, rsa, six, python-dateutil, jmespath, urllib3, botocore, s3transfer, colorama, PyYAML, awscli
Successfully installed PyYAML-5.4.1 awscli-1.20.54 botocore-1.21.54 colorama-0.4.3 jmespath-0.10.0 pyasn1-0.4.8 python-dateutil-2.8.2 rsa-4.7.2 s3transfer-0.5.0 six-1.16.0 urllib3-1.26.7
[ec2-user@ip-xxx-xxx-xxx-xxx ~]
  • aws cliバージョン1をアンインストールします。
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ pip3 uninstall awscli
Found existing installation: awscli 1.20.54
Uninstalling awscli-1.20.54:
  Would remove:
    /home/ec2-user/.local/bin/aws
    /home/ec2-user/.local/bin/aws.cmd
    /home/ec2-user/.local/bin/aws_bash_completer
    /home/ec2-user/.local/bin/aws_completer
    /home/ec2-user/.local/bin/aws_zsh_completer.sh
    /home/ec2-user/.local/lib/python3.7/site-packages/awscli-1.20.54.dist-info/*
    /home/ec2-user/.local/lib/python3.7/site-packages/awscli/*
Proceed (y/n)? y
  Successfully uninstalled awscli-1.20.54
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$
  • アンインストールされたことを確認します。
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ aws --version
-bash: /home/ec2-user/.local/bin/aws: No such file or directory
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$
  • aws cliバージョン2をインストールします。
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$  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 42.4M  100 42.4M    0     0   112M      0 --:--:-- --:--:-- --:--:--  113M
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ unzip awscliv2.zip
Archive:  awscliv2.zip
   creating: aws/
   creating: aws/dist/
  inflating: aws/install
  inflating: aws/THIRD_PARTY_LICENSES
  inflating: aws/README.md
~省略~
  inflating: aws/dist/cryptography-3.3.2-py3.8.egg-info/LICENSE.APACHE
  inflating: aws/dist/cryptography-3.3.2-py3.8.egg-info/LICENSE
  inflating: aws/dist/cryptography-3.3.2-py3.8.egg-info/METADATA
   creating: aws/dist/zlib/cpython-38-x86_64-linux-gnu/
  inflating: aws/dist/zlib/cpython-38-x86_64-linux-gnu/soib.cpython-38-x86_64-linux-gnu.so
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo ./aws/install
You can now run: /usr/local/bin/aws --version
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$
  • バージョンを確認します。aws コマンドが見つからない場合は、現在のセッションにてプロファイルを読み直します。
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ aws --version
-bash: /home/ec2-user/.local/bin/aws: No such file or directory
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ source ~/.bash_profile
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ aws --version
aws-cli/2.2.43 Python/3.8.8 Linux/4.14.243-185.433.amzn2.x86_64 exe/x86_64.amzn.2 prompt/off
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$

以上で、AmazonLinux2において、aws cliのバージョンを1から2へ変更する方法についての説明は終了となります。

記載されている会社名、システム名、製品名は一般に各社の登録商標または商標です。

当社製品以外のサードパーティ製品の設定内容につきましては、弊社サポート対象外となります。

Linux系OSにaws cliバージョン2をインストールする方法について前のページ

監視項目データベース更新案内(211111_01)次のページ

ピックアップ記事

  1. ログフォワーダー「okurun.jar」について
  2. IoT機器「Raspberry pi」とLogStare Collectorで温…
  3. Zabbixヒストリデータのレポート生成について
  4. 自社製品をAMIにしてAWSマーケットプレイスへ出品

関連記事

  1. Windows/Linux

    Apache(httpd)のアクセスログの収集について

    当記事では、Apache(httpd)のアクセスログの収集について記載…

  2. AWS/Azure

    自社製品をAMIにしてAWSマーケットプレイスへ出品

    はじめにかねてより弊社製品のAWSマーケットプレイス出品を目論んで…

  3. Windows/Linux

    Linux系OSにaws cliバージョン2をインストールする方法について

    当記事では、Linux系OSにaws cliをインストールする方法につ…

  4. NW機器

    D-Link製DGS-3000シリーズ及びDGS-3120シリーズにおけるSYSLOG/SNMP設定…

    当記事では、D-Link製DGS-3000シリーズ及びDGS-3120…

  5. AWS/Azure

    LogStare CollectorでのVPCフローログの取得方法とログレポート

    当記事では、LogStare CollectorでのVPCフローログの…

  6. Windows/Linux

    Linux/Windows pingコマンドの使い方とオプションについて

    当記事では、Linux/Windowsのpingコマンドの使い方とオプ…

月額200円でM356の監査ログの運用レベルUP LogStare M365

AWSのログ分析・モニタリングに 次世代のマネージド・セキュリティ・プラットフォーム LogStare

  1. NW機器

    PaloAltoのIPsec IKEv1 Phase1におけるトラブルシューティ…
  2. デフォルト画像イメージ

    FortiGate

    FortiGateのSD-WAN設定について
  3. NW機器

    SonicWall UTMにSyslog送信設定を追加する方法について
  4. SNMPを触ってみた

    ログ分析・監視テクニック

    SNMPとは?新入社員が生まれてはじめて触ってみた!
  5. 実践記事

    DNSキャッシュポイズニングやってみた
PAGE TOP