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でSSOログイン

Last updated at Posted at 2025-06-01

はじめに

AWSを個人で使い始め、約半年。半年前は毎日いろいろいじっていたけど、最近はご無沙汰。
なんでだろう。と思ったけど、要因の1つにログインがめんどくさいな。って思ったところ。

そこで、AWS-CLIだったらもう少し楽にログインできないかな?と思って、久々にAWSの世界にダイブ。
また直ぐに忘れるので、残します

前提

ユーザは「IAM Identity Center」で作成したのを使う。

初回設定

aws configure sso
$ aws configure sso
SSO session name (Recommended): なんでも ※1
SSO start URL [None]: 「IAM Identity Center」の「AWS access portal URL」※2
SSO region [None]: 「IAM Identity Center」のリージョン
SSO registration scopes [sso:account:access]:デフォルトママ

※1 最初は「IAM Identity Center」で作ったユーザ名を指定していたけど、任意の文字列でも大丈夫だった。最終的には管理しやすい任意の文字列にした。
※2 「IAM Identity Center」の「アイデンティティソース」の「AWS access portal URL」

で、あとは流れのままに。

プロファイル名を「default」で登録しておくと後が便利かも。

作成された情報は、「.aws/config」に格納されている感じ。
なので、あとから名称等を変更したい場合は直接編集しても大丈夫そう。

そのあとの使い方

aws コマンド実行時に「--profile」を指定する。
※ default で作っておけば指定不要。

 --profile プロファイル名

初回設定後のログイン処理

aws sso login --profile プロファイル名

ブラウザが自動で立ち上がるので、「IAM Identity Center」で作ったユーザ名/パスワード等を使い、ログインする。

ちょっと試す

aws s3 ls --profile プロファイル名

使い終わったら、ログアウト

aws sso logout --profile プロファイル名
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?