aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

AWS SSO login with Assume role profile

Open barakharyati opened this issue 5 years ago • 2 comments

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

barakharyati avatar May 24 '21 18:05 barakharyati

Hi @barakharyati,

Thanks for the feature request!

stobrien89 avatar May 26 '21 16:05 stobrien89

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

adamdodev avatar Oct 18 '22 11:10 adamdodev