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 3 years have passed since last update.

【Mac】AWS CLI インストール手順の備忘録

Last updated at Posted at 2021-03-27

はじめに

  • Mac環境に AWS CLI をインストールする機会があったので、その備忘録です。

動作環境

  • macOS Catalina 10.15.7

手順

AWS CLI のインストール

  1. インストーラをダウンロードします。
  2. DLしたインストーラ(pkgファイル)を実行し、インストールします(全てデフォルト設定でOK)。
  3. インストールを確認します。
shell
$ which aws
# → /usr/local/bin/aws
$ aws --version
# → aws-cli/2.1.32 Python/3.8.8 Darwin/19.6.0 exe/x86_64 prompt/off

AWS CLIの設定

  • aws configureコマンドで実行ユーザの認証情報(プロファイル)を紐付けます。
shell
$ aws configure
# IAMユーザのアクセスキー設定
AWS Access Key ID [None]: xxxxxxxx
# IAMユーザのシークレットアクセスキー設定
AWS Secret Access Key [None]: yyyyyyyy
# リージョン設定:東京
Default region name [None]: ap-northeast-1
# 出力設定:json
Default output format [None]: json
  • ホームディレクトリ直下に.awsフォルダが作成され、そのフォルダ内にconfigファイルとcredentialsファイルが出力されます。
.aws\config
[default]
region = ap-northeast-1
output = json
.aws\credentials
[default]
aws_access_key_id = xxxxxxxx
aws_secret_access_key = yyyyyyyy
  • CLIに紐付いているプロファイルを確認します。
shell
$ aws configure list 
#      Name                    Value             Type    Location
#      ----                    -----             ----    --------
#   profile                <not set>             None    None
# access_key     ****************xxxx shared-credentials-file    
# secret_key     ****************yyyy shared-credentials-file    
#     region           ap-northeast-1      config-file    ~/.aws/config
  • CLIのプロファイルを一時的に変更してみます。
.aws\config
[default]
region = ap-northeast-1
output = json

[profile user1]
region = ap-northeast-1
output = json
.aws\credentials
[default]
aws_access_key_id = xxxxxxxx
aws_secret_access_key = yyyyyyyy

[user1]
aws_access_key_id = zzzzzzzz
aws_secret_access_key = aaaaaaaa
shell
$ aws configure list --profile user1
#      Name                    Value             Type    Location
#      ----                    -----             ----    --------
#   profile                <not set>             None    None
# access_key     ****************zzzz shared-credentials-file    
# secret_key     ****************aaaa shared-credentials-file    
#     region           ap-northeast-1      config-file    ~/.aws/config
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?