LoginSignup
13
7

More than 1 year has passed since last update.

AWS CLIでAWS SSOを使用する

Last updated at Posted at 2022-11-30

概要

AWS CLIでSSOの初期設定をする際の手順をよく失念するので、主に自分用の備忘録です。

前提

  • AWS CLIのインストール
  • direnvでAWS_PROFILE設定済み(これは --profile を省略する為に使用しています)

プロファイルの設定

aws configure sso
% aws configure sso
SSO session name (Recommended): [ここは既存のセッション名と重複しなければ自由に設定OKです]
SSO start URL [None]: [ここはSSOでアクセスするURLを指定します]
SSO region [None]: [ここはリージョンの指定です]
SSO registration scopes [sso:account:access]: sso:account:access

ここまで対話式で入力するとデフォルトブラウザが起動します。
ブラウザの方でSSOログインすると自動でコードの入力までされます。
(ブラウザを閉じてしまったなど中断してしまった場合はコンソールに下記のようなメッセージが表示されているので、URLをブラウザに入力してSSOログインし、表示されているコードを入力します。

Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:

https://device.sso.ap-northeast-1.amazonaws.com/

Then enter the code:

XXXX-XXXX

無事ログインできたらアクセスするAWSアカウントの指定をします。
候補が出てくるので選択します。

There are NN AWS accounts available to you.

無事アクセスするAWSアカウントの指定が終わると、今度は使用するロールの指定をします。
これも候補が出てくるので選択します。

Using the account ID XXXXXXXXXXXX
There are N roles available to you.

使用するロールの指定も終わるとデフォルトでクライアントがアクセスするリージョンと出力フォーマットの指定を行い、完了です。

Using the role name "AdministratorAccess"
CLI default client Region [None]: ap-northeast-1
CLI default output format [None]: json

To use this profile, specify the profile name using --profile, as shown:

次回以降のログイン

以下コマンドを実行すると、標準ブラウザで許可画面に遷移します。

aws sso login

許可するとSSOログインは完了です。

参照

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