LoginSignup
300
269

More than 3 years have passed since last update.

AWS-CLIの初期設定のメモ

Last updated at Posted at 2017-10-23

概要

aws-cliを使い始めたので、設定について軽くメモを残す。

AWS-CLI準備

下記マニュアルを参考に、awsコマンドをインストールしてコマンドが使えるようにする。

aws-cli.png
AWS CLI のインストールと設定

aws-cliインストール(Mac)

Windowsの場合は、マニュアルに記載されている MSIのダウンロード を参照

ターミナル
$ sudo pip install awscli

or

$ brew install awscli

aws-cliインストール(Linux)

Linux環境にインストールする場合の例です。

ターミナル
# pythonのバージョン確認 (Python 2.6.5+ or Python 3.3+ )
$ python --version

# pipインストール
# ※ --user で、pipのスクリプトを ~/.local/bin にインストール
$ curl -O https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py --user 
$ echo export PATH='~/.local/bin:$PATH' >> ~/.bash_profile
$ source ~/.bash_profile
$ pip --version

# aws-cliインストール
# ※ --user で、pipのスクリプトを ~/.local/bin にインストール
$ pip install awscli --upgrade --user
$ aws --version

インストールを確認

ターミナル
$ which aws
/usr/local/bin/aws

$ aws --version
aws-cli/1.11.174 Python/2.7.10 Darwin/16.7.0 botocore/1.7.32

aws-cliの設定

ターミナル
$ aws configure --profile user1
AWS Access Key ID [None]: {アクセスキー(各自)}
AWS Secret Access Key [None]: {シークレットアクセスキー(各自)}
Default region name [None]: ap-northeast-1
Default output format [None]: json

IAMユーザーを確認してみる

ターミナル
$ aws iam list-users
{
    "Users": [
               ・
               ・
               ・
    ]
}

IAMグループを確認してみる

ターミナル
$ aws iam list-groups
{
    "Groups": [
               ・
               ・
               ・
    ]
}

プロファイルの確認

現在のプロファイル(デフォルト)

ターミナル
$ aws configure list

指定のプロファイル

ターミナル
$ aws configure list --profile user1

プロファイル切り替え(一時的)

ターミナル
$ aws s3 ls --profile user1

プロファイル切り替え(デフォルト)

ターミナル
# デフォルト変更
$ export AWS_DEFAULT_PROFILE=user1

# 確認
$ aws configure list

または、

ターミナル
# デフォルト変更
$ export AWS_PROFILE=user1

# 確認
$ aws configure list

参考資料

300
269
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
300
269