B. Hamonangan <70834922+hamonangann@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date
Message
feat(aws): add support for sso sessions login (#12090)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Diff
1diff --git a/plugins/aws/README.md b/plugins/aws/README.md
2index 4850e223eaeb4e046c6ee077568706ea52419cd8..dbf8dcfeb8b829f760232a1fdbf882bd5934202a 100644
3--- a/plugins/aws/README.md
4+++ b/plugins/aws/README.md
5@@ -16,6 +16,7 @@ plugins=(... aws)
6 It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It sets `$AWS_PROFILE_REGION` for display in `aws_prompt_info`.
7 Run `asp` without arguments to clear the profile.
8 * `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
9+* `asp [<profile>] login [<sso_session>]`: In addition to `asp [<profile>] login`, if SSO session has been configured in your aws profile, it will run the `aws sso login --sso-session <sso_session>` command following profile selection.
10 * `asp [<profile>] logout`: If AWS SSO has been configured in your aws profile, it will run the `aws sso logout` command following profile selection.
1112 * `asr [<region>]`: sets `$AWS_REGION` and `$AWS_DEFAULT_REGION` (legacy) to `<region>`.
13diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh
14index 0d7040f9275a82290131b9d4be2f825316f60d86..fd00714e72c6ffab39e62966dc68a215b9206a7a 100644
15--- a/plugins/aws/aws.plugin.zsh
16+++ b/plugins/aws/aws.plugin.zsh
17@@ -29,7 +29,11 @@ function asp() {
18 export AWS_PROFILE_REGION=$(aws configure get region)
1920 if [[ "$2" == "login" ]]; then
21- aws sso login
22+ if [[ -n "$3" ]]; then
23+ aws sso login --sso-session $3
24+ else
25+ aws sso login
26+ fi
27 elif [[ "$2" == "logout" ]]; then
28 aws sso logout
29 fi