trek10inc / awsume

A utility for easily assuming AWS IAM roles from the command line.
https://awsu.me
MIT License
488 stars 90 forks source link

No such file or directory #68

Closed alexbilbie closed 4 years ago

alexbilbie commented 4 years ago

Hello,

I have a few profiles configured two of which are called platform-production-admin and shared-services-admin.

Earlier today I ran . awsume shared-services-admin -a (no issues).

A few hours later (in the same terminal window) I've typed . awsume platform-production-admin -a and I see this output:

$ . awsume platform-production-admin -a
Session token will expire at 2019-09-27 23:32:44
Role credentials will expire 2019-09-27 14:57:00
[3] 2930
$ Traceback (most recent call last):
  File "/usr/local/bin/autoawsume", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/awsume/autoawsume/main.py", line 26, in main
    subprocess.run(auto_profile.get('awsumepy_command').split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 472, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'shared-services-admin': 'shared-services-admin'

The traceback is automatically output into the terminal after hitting enter on the . awsume platform-production-admin -a command.

How can I stop this from happening?

If it helps at all I'm on macOS 10.14.5, I installed Python via Homebrew and awsume via pip

mbarneyjr commented 4 years ago

Howdy!

I was able to replicate the issue and will dig into finding a solution

Thanks for bringing this to our attention!

furudean commented 4 years ago

Was this addressed in https://github.com/trek10inc/awsume/commit/3ed8fad276feb64192c95464df58ea13e8c19213?

mbarneyjr commented 4 years ago

@c-bandy Yeah, that was the commit that fixed it

I deployed the fix to 4.1.5, thanks again for the bug report!

furudean commented 4 years ago

This seems to have caused another issue, because auto doesn't work for me anymore


$ awsume profile -a
Traceback (most recent call last):
  File "/usr/local/bin/awsumepy", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/awsume/awsumepy/main.py", line 29, in main
    run_awsume(sys.argv[1:])
  File "/usr/local/lib/python3.7/site-packages/awsume/awsumepy/main.py", line 17, in run_awsume
    awsume.run(argument_list)
  File "/usr/local/lib/python3.7/site-packages/awsume/awsumepy/app.py", line 247, in run
    credentials = self.get_credentials(args, profiles)
  File "/usr/local/lib/python3.7/site-packages/awsume/awsumepy/app.py", line 202, in get_credentials
    credentials = self.plugin_manager.hook.get_credentials(config=self.config, arguments=args, profiles=profiles)
  File "/usr/local/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 92, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 86, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/usr/local/lib/python3.7/site-packages/awsume/awsumepy/default_plugins.py", line 470, in get_credentials
    user_session, role_session = get_assume_role_credentials_mfa_required(config, arguments, profiles, target_profile)
  File "/usr/local/lib/python3.7/site-packages/awsume/awsumepy/default_plugins.py", line 387, in get_assume_role_credentials_mfa_required
    if arguments.auto_refresh and os.environ.get('AWS_PROFILE').startswith('autoawsume-'):
AttributeError: 'NoneType' object has no attribute 'startswith'```
mbarneyjr commented 4 years ago

Fix pushed to 4.1.6, if you still have any issues feel free to reopen the issue or open a new issue, thanks!