2
3

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

AWSを使用する任意のコマンドでassume roleする方法

2
Last updated at Posted at 2016-10-14

AWS CLIとかだと--profileを使えばいいが、serverlessとかだとこういう機能を用意してくれていない場合がある(profileを設定できるがassume roleしてくれない)。そんな時に使えるコマンド

eval "`aws sts assume-role --role-arn [role-arn] --role-session-name assume-role-temporary | jq -r '"AWS_ACCESS_KEY_ID="+.Credentials.AccessKeyId+" AWS_SECRET_ACCESS_KEY="+.Credentials.SecretAccessKey+" AWS_SESSION_TOKEN="+.Credentials.SessionToken'` [したいこと]"
  • AWS CLIは使えるようになっているという前提
  • jqがインストールされているという前提
  • [role-arn]にassumeするロールのARNを指定
  • [したいこと]には例えばserverless deployとかを入れる
2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?