Closed pputnik closed 4 years ago
Update: awsume profilename
in scripts just doesn't work:
+ awsume secondary
AWSume: User profile credentials will expire at: 2019-08-01 20:10:44
AWSume: Role profile credentials will expire at: 2019-08-01 15:01:32
+ aws sts get-caller-identity
{
"UserId": "AIDAR355SJBCL57WUCIW3",
"Account": "111111111",
"Arn": "arn:aws:iam::111111111:user/username"
}
and
+ awsume secondary
AWSume: User profile credentials will expire at: 2019-08-01 20:10:44
AWSume: Role profile credentials will expire at: 2019-08-01 15:03:47
+ aws --profile secondary sts get-caller-identity
An error occurred (AccessDenied) when calling the AssumeRole operation: Access denied
Please help.
I believe the problem stems from the fact that aliases are not expanded for non-interactive shells in bash (see https://unix.stackexchange.com/questions/1496/why-doesnt-my-bash-script-recognize-aliases). Since the alias simply source
s the shell script, you can just do something like this in your scripts:
source awsume <profile_name>
or:
. awsume <profile_name>
Closing for inactivity. Feel free to open an issue if you're still experiencing issues
Hello,
I know we can switch profiles with
awsume profile_name
but in scripts we want to be able to use old goodaws --profile profile_name command_name
too because we're working with more than one account within the same script.Is there a workaround? Using
awsume profilename
in script is a bit awkwardly and I'm afraid we'll have a mess with aws-related system variables.Thank you.