cevoaustralia / aws-google-auth

Provides AWS STS credentials based on Google Apps SAML SSO auth (what a jumble!)
MIT License
537 stars 181 forks source link

default when only one role to assume #93

Open rafilkmp3 opened 6 years ago

rafilkmp3 commented 6 years ago

hi, when we have only one role to assume the following dialog is prompt. if i press a simple enter without choose 1 I face this error:

Type the number (1 - 1) of the role to assume:

Traceback (most recent call last): File "/usr/local/bin/aws-google-auth", line 11, in sys.exit(main()) File "/usr/local/lib/python2.7/site-packages/aws_google_auth/init.py", line 226, in main cli(cli_args) File "/usr/local/lib/python2.7/site-packages/aws_google_auth/init.py", line 65, in cli process_auth(args, config) File "/usr/local/lib/python2.7/site-packages/aws_google_auth/init.py", line 213, in process_auth config.role_arn, config.provider = util.Util.pick_a_role(roles) File "/usr/local/lib/python2.7/site-packages/aws_google_auth/util.py", line 53, in pick_a_role return list(roles.items())[int(choice) - 1] ValueError: invalid literal for int() with base 10: 'Type the number (1 - 1) of the role to assume:'

mide commented 6 years ago

This could likely be added as a small if at the top of the pick_a_role() function. https://github.com/cevoaustralia/aws-google-auth/blob/91cb4f764655082631b61d8c1ba07742dbe9f6f0/aws_google_auth/util.py#L18-L19

I think it can be something really simple, like the following. I don't have the time right now to test/make a PR, but this is a start.

if len(roles) == 1:
    return roles[0]