0
0

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 1 year has passed since last update.

AWSCLI v1とv2の共存環境でv2を更新する手順メモ

Posted at

この記事は仕事用のメモ。
使い終わったら消す予定。

■お家検証内容

yum install zip unzip -y

yum install centos-release-scl -y
yum repolist all | grep -e centos-sclo -e rhel-server-rhscl-7-rpms -e software
yum install rh-python38 -y
scl enable rh-python38 bash
python -V

cd /tmp/

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.1.36.zip" -o "awscliv2.zip"

curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"

unzip awscliv2.zip; unzip awscli-bundle.zip

sudo /tmp/aws/install -i /usr/local/aws-cli -b /usr/local/bin; aws --version

-i : ライブラリを含むインストール資産の配置先ディレクトリ (default:/usr/local/aws-cli)
-b : 実行コマンドのシンボリックリンクを作成するディレクトリ(default:/usr/local/bin)

rm -rf /tmp/aws

ln -s /usr/local/aws-cli/v2/current/bin/aws /usr/local/bin/aws2 unlink /usr/local/bin/aws

sudo /opt/rh/rh-python38/root/usr/bin/python /tmp/awscli-bundle/install -i /usr/local/aws-cli-v1 -b /usr/local/bin/aws

-i : ライブラリを含むインストール資産の配置先ディレクトリ (default:~/.local/lib/aws)
-b : 実行コマンドのシンボリックリンクのパス (default:シンボリックリンクを作成しない)

rm -rf /tmp/awscli-bundle


aws --version; aws2 --version
aws-cli/1.27.70 Python/3.8.13 Linux/3.10.0-1127.el7.x86_64 botocore/1.29.70
aws-cli/2.1.36 Python/3.8.8 Linux/3.10.0-1127.el7.x86_64 exe/x86_64.centos.7 prompt/off


curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.9.23.zip" -o "awscliv2.9.23.zip"

unzip awscliv2.9.23.zip

sudo /tmp/aws/install -u -i /usr/local/aws-cli -b /usr/local/bin; aws --version; aws2 --version

ln -sf /usr/local/aws-cli-v1/bin/aws /usr/local/bin/aws


aws --version; aws2 --version
aws-cli/1.27.70 Python/3.8.13 Linux/3.10.0-1127.el7.x86_64 botocore/1.29.70
aws-cli/2.9.23 Python/3.9.11 Linux/3.10.0-1127.el7.x86_64 exe/x86_64.centos.7 prompt/off


■開発環境でやるべきこと

'*** 最新AWSCLIv2をダウンロード&サーバへ格納(/tmp)
'*** URL : https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
'*** rename awscli-exe-linux-x86_64.zip awscliv2.zip
cd /tmp/
unzip awscliv2.zip

'*** シンボリックリンクの状況を整理、記録
ll /usr/local/bin/aws*

'*** 各AWSCLIのバージョンを確認、記録
aws --version
aws2 --version

'*** AWSCLIv2を更新インストール
sudo /tmp/aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update

'*** シンボリックリンクの状況を整理、記録
ll /usr/local/bin/aws*

'*** シンボリックリンク「/usr/local/bin/aws」 にAWSCLIv1が、
'*** シンボリックリンク「/usr/local/bin/aws2」にAWSCLIv2が、
'*** それぞれ登録されるようにln -sfコマンドで修正
ln -sf /usr/local/aws-cli-v1/bin/aws /usr/local/bin/aws
ln -sf /usr/local/aws-cli/v2/current/bin/aws /usr/local/bin/aws2

'*** お片付け
rm -f awscliv2.zip
rm -rf aws/

おわり

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?