trek10inc / awsume

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

awsume in shell scripts #155

Closed Nemunas closed 3 years ago

Nemunas commented 3 years ago

I'm trying to run awsume in a shell script but getting an error:

#!/bin/bash

awsume [ role ] --refresh

/home/me/.local/bin/awsume: line 181: return: can only 'return' from a function or sourced script

mbarneyjr commented 3 years ago

The awsume shell script expects to be sourced. An alias should be loaded into your login file automatically when awsume itself is installed, but that can fail. Running awsume-configure should try to set awsume up for all installed shells after installation

We'll see how we can add a warning to the shell script if it's not being sourced to help make this a little more clear. If you still have any issues after setting up the alias and reloading your terminal, feel free to re open this issue or create a new one!

adnan-asad01 commented 1 year ago

Why doesn't awsume-configure add the alias to .zshrc as well? @mbarneyjr

stuertz commented 12 months ago

solution from #163 is to use source

#!/bin/bash

source awsume [ role ] --refresh