AWS SSO login with Assume role profile
Automatically pull SSO login details from source_profile while running
aws sso login command with assume role profile
assuming role setting up an assume-role profile with
example config File
[profile 12345678901-sso-LoginProfile]
sso_start_url = https://example.awsapps.com/start
sso_region = us-east-1
sso_account_id = 12345678901
sso_role_name = AdministratorAccess
region = eu-central-1
output = json
[profile 12345678901-sso-assumeRoledProfile]
role_arn = arn:aws:iam::12345678901:role/exampleRole
region = us-east-1
source_profile = 12345678901-sso-LoginProfile
Terminal
export AWS_PROFILE=12345678901-sso-assumeRoledProfile
aws sso login
Hi @barakharyati,
Thanks for the feature request!
If anyone stumbles across this waiting for this feature, a slightly messy workaround is to duplicate the SSO settings in to the assume role profile:
# SSO Role for logging in
[profile LoginRole]
sso_start_url = https://example.awsapps.com/start
sso_region = eu-central-1
sso_account_id = 0123456789
sso_role_name = LoginRole
# Assumed Role
[profile AssumeRole]
role_arn = arn:aws:iam::0123456789:role/AssumeRole
# Duplicate the SSO details here so we can login and switch role in one command
sso_start_url = https://example.awsapps.com/start
sso_region = eu-central-1
sso_account_id = 0123456789
sso_role_name = LoginRole
# We still need to supply a valid source_profile with role_arn, even though we have the SSO details right here
source_profile = LoginRole
region = eu-central-1
Then SSO log in using the assume role profile:
export AWS_PROFILE=AssumeRole
aws sso login
aws sts get-caller-identity