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

Profile in aws/config has a space in it, awsume doesn't see it. #145

Closed Mitictonylor closed 9 months ago

Mitictonylor commented 3 years ago

Hi there, i have a profile called "profile default" and i have to keep it in this format, when i run awsume profile default this doesn't' work and neither if i wrap the profile name in quotes. Screenshot 2021-04-26 at 14 52 46 Screenshot 2021-04-26 at 14 53 22

Awsume version 4.5.0

mbarneyjr commented 3 years ago

Profile configuration is split up between ~/.aws/config and ~/.aws/credentials files. Profiles in the ~/.aws/config file are prefixed with profile (with a space), where ~/.aws/credentials profiles don't have a prefix. The exception being the default profile, that does not get a prefix in either of the two files

So having a profile named profile default in the ~/.aws/config file isn't what you'd necessarily want to do. If you changed the default in profile default to something like myrole, you could then run awsume myrole and I think that's what you'd want to be able to do

Also note the source_profile property is meant to specify the profile who's credentials you want to use to call the assume-role operation, which should generally be a different profile from itself - note the source_profile documentation here

If you're interested to learn more, I've got it documented some things here, with some links to the AWS documentation and another helpful writeup

Doing some testing, I did notice that profiles with spaces do break the awsume shell wrapper though, but that's not the issue you're experiencing now. I'll leave this open as an issue to resolve that

mtskillman commented 10 months ago

need to address this part -> profiles with spaces do break the awsume shell wrapper though

mtskillman commented 9 months ago

cannot replicate this part [when using 4.5.3]

need to address this part -> profiles with spaces do break the awsume shell wrapper though

moreover, spaces in profile name should not be allowed due to

Awsume error: An error occurred (ValidationError) when calling the AssumeRole operation: 1 validation error detected: Value 'my test' at 'roleSessionName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w+=,.@-]*