LoginSignup
0
0

More than 1 year has passed since last update.

aws cliを複数のプロファイルで使う

Last updated at Posted at 2020-02-05

aws cliで複数のプロファイルを使う方法について記載

すでにaws cliインストール、デフォルトのプロファイルが設定されている前提。

1.新しいプロファイルを作成する

$aws configure --profile new-user

AWS Access Key ID [None]: xxxxxxxxxxxxxx
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxx
Default region name [None]: ap-northeast-1
Default output format [None]: json

Default output formatについては以下のような感じ、

json – JSON 文字列形式で出力されます。
yaml – YAML 文字列形式で出力されます。(AWS CLI バージョン 2 でのみ利用できます。)
text – 複数行のタブ区切り文字列値の形式で出力されます。これは、grep、sed、または awk などのテキストプロセッサに出力を渡すのに役立ちます。
table – セルの罫線を形成する文字列 +|- を使用して表形式で出力されます。通常、情報は他の形式よりも読みやすい「わかりやすい」形式で表示されますが、プログラムとしては役立ちません。

2.プロファイルを指定してコマンドを実行する

$aws s3 ls --profile new-user

3.面倒な場合は、環境変数で指定する

$export AWS_PROFILE=new-user

補足、デフォルトユーザーの変更

$export AWS_DEFAULT_PROFILE=new-user

以上

参考

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