WindowsでBashシェルを実行する!その2-UbuntuにAWS CLIの環境設定

前提

WindowsでBashシェルを実行する!その1-WSL2にUbuntuをインストール」では、Windows10にのWSL2にUbuntuをインストールする手順を紹介しました。

ここでは、UbuntuにAWS CLIの環境を設定する手順を紹介します。

動作環境

・Windows10 Home(バージョン:20H2 OSビルド:19042.1348)

・Ubuntu 20.04

UbuntuにAWS CLIの環境設定

AWS CLIのインストールファイルをダウンロードします。

コマンド:

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

実行例:

kobayashi@DESKTOP-2T7SGEG:~$ 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 43.3M  100 43.3M    0     0  4848k      0  0:00:09  0:00:09 --:--:-- 5285k

Ubuntuにunzipインストールする

コマンド:

sudo apt-get install zip

実行例:
デフォルトユーザーのパスワードを聞かれますので、入力してEnterキーを押下するとインストールされます。

kobayashi@DESKTOP-2T7SGEG:~$ sudo apt-get install zip
[sudo] password for kobayashi:

インストーラを解凍します。

コマンド:

unzip awscliv2.zip

インストールプログラムを実行します。

コマンド:

sudo ./aws/install

AWS CLI の設定

AWS Access Key ID [None]: <Your AWS Access Key>
AWS Secret Access Key [None]: <Your AWS Secret Access Key>
Default region name [None]: ap-northeast-1
Default output format [None]: json

設定した場合、下記のように表示されます。

kobayashi@DESKTOP-2T7SGEG:~$ aws configure
AWS Access Key ID [****************6YRX]:
AWS Secret Access Key [****************tkd5]:
Default region name [ap-northeast-1]:
Default output format [json]:
kobayashi@DESKTOP-2T7SGEG:~$

aws s3のコマンドを実行してみる。

kobayashi@DESKTOP-2T7SGEG:~$ aws s3 ls
2021-10-26 16:21:33 cf-templates-onhdcbsit40h-ap-northeast-1

参考

Linux での AWS CLI バージョン 2 のインストール、更新、アンインストール

AWS CLIの設定

Last modified: 2021-12-07

Author