trek10inc / awsume

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

the awsume shell script is not being sourced #186

Closed globetrotter2796 closed 10 months ago

globetrotter2796 commented 2 years ago

After the awsume command is applied it gives the following error:

I am trying to run a shell script, which uses AWSUME inside the shell script to assume role i to multiple accounts one by one in the script,

ISSUE:

Warning: the awsume shell script is not being sourced, please use awsume-configure to install the alias Session token will expire at 2022-06-18 02:03:46 [AWS-account-role} Role credentials will expire 2022-06-17 15:09:50

/opt/homebrew/bin/awsume: line 183: return: can only `return' from a function or sourced script An error occurred (InvalidClientTokenId) when calling the ListUsers operation: The security token included in the request is invalid.

But if i assume a role individually to an account it works fine.

TimXL commented 1 year ago

Try adding this line to your bash script shopt -s expand_aliases.

I spent a while on this error and found this fixed it.

See here for explaination https://www.thegeekdiary.com/how-to-make-alias-command-work-in-bash-script-or-bashrc-file/

mtskillman commented 10 months ago

closing -- considering as resolved