AWS CLIでSSOを使ってログインする方法
AWS IIC(Identity Center)を使用している場合、AWS CLIでSSOを使ってログインすることができます。
IICについての記事はこちら
https://qiita.com/soranjiro/items/8b0c38394b3349891184
認証
SSO(シングルサインオン)を使用してAWS CLIにログインします。
$ aws configure sso
# SSOのセッション名を指定します。
SSO session name (Recommended): <your-session-name>
# 初回は以下を入力
SSO start URL [None]: https://xxxxxxxxxx.awsapps.com/start
SSO region [None]: ap-northeast-1
SSO registration scopes [None]: sso:account:access
# アカウントが複数ある場合は、アカウントを選択
> production, mail@address.com (xxxxx)
staging, mail@address.com (xxxxx)
# プロファイルを選択
> AdministratorAccess
DevelopmentAccess
ReadOnlyAccess
# regionの選択
Default client Region [None]: ap-northeast-1
CLI default output format [None]: json
# localでのプロファイル名を設定
Profile name [None]: <your-profile-name>
セッションの確認
以下のコマンドで、ログインできていることを確認します。
$ aws sts get-caller-identity --profile axi
{
"UserId": "xxxxxxxxxxxx",
"Account": "xxxxxxxxxxxx",
"Arn": "arn:aws:iam::xxxxxxxxxxxx:user/username"
}
これで、SSOを使ってAWS CLIにログインできました。