LoginSignup
1
1

More than 3 years have passed since last update.

AWSをコマンドラインで扱うときに--profileってるけるのが面倒なのでdirenvをつかったほうがいい

Posted at

aws cliを使うときに複数のprofileを使っていると時々間違えた環境に対して操作を行ってしまったりしてヒヤッとすることがある

--profileをつけわすれてワーみたいな

なのでdirenvという該当のディレクトリの中だけで環境変数を設定できるツールをつかっている
https://github.com/direnv/direnv

該当のディレクトリに「.envrc」というファイルを作成して
以下のコマンド

direnv edit .

中身をこんなふうにしておく⇣

export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxx

そうしたらawsコマンドを使う前に

direnv arrow

とすると.envrcの中の変数が該当ディレクトリ内だけで反映されるので
「--profile」ってつけなくても大丈夫になるのでヒューマンエラーを防げる

おしまい

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