1
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?

AWS CLI プロファイルの切り替えコマンド

Posted at

この記事について

仕事上、AWSのアカウントを複数使い分けることがあります。
CLIのプロファイルの切り替え方を毎回調べているのでまとめておきます。

コマンド

設定済みのプロファイルを一覧にする

aws configure list-profiles

このコマンドで、~/.aws/config 配下に入った [profile ]の情報および ~/.aws/credentials 配下に認証情報が入っているプロファイルの情報が一覧で表示される。

プロファイルを切り替える

export AWS_PROFILE=プロファイル名

これで、シェルのセッション中はオプションで明示しない限り設定したプロファイル情報でコマンドが実行される。

プロファイルを新規で作成する場合

プロファイルを新規で作成する場合は、必要な権限を持つ IAM ロールを作成した上で、そのIAMロールのアクセスキーを取得した上で以下を実行する。

aws configure --profile プロファイル名

対話形式で以下の項目を聞かれるので入力する。

AWS Access Key ID [None]: AKIAxxxxxxxxxxxx
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxxxx
Default region name [None]: ap-northeast-1
Default output format [None]: json
1
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
1
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?