victorskl / yawsso

Yet Another AWS SSO - sync up AWS CLI v2 SSO login session to legacy CLI v1 credentials
MIT License
302 stars 26 forks source link

Tildes aren't being expanded on file paths #33

Closed aisamu closed 3 years ago

aisamu commented 3 years ago

Hi!

It looks like some assertions are using the "raw" paths to check for file existence: https://github.com/victorskl/yawsso/blob/75000b1eb7a7dc84ced88a318ef07152d8b024ea/yawsso/cli.py#L409-L411

(the above's from version 0.5, currently available on pip, but it also appears to be present on 0.6rc)

That's leading to failures when the paths contain a tilde (i.e. for the user's home). I've confirmed that manually expanding the path on the config vars solved it.

$> yawsso 
~/xxx/aws/config does not exists

$> bat ~/xxx/aws/config                                                                                               <aws:stedi>
───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /Users/aisamu/xxx/aws/config
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ [xxx]
   2   │ region=us-east-1
   3   │ duration_seconds = 43200
   4   │
   5   │ [profile xxx/dev]
   6   │ ... 

Apparently, the expansion has to be done explicitly on Python 😞: https://stackoverflow.com/a/2057072

Thanks for this super useful tool!

victorskl commented 3 years ago

Thanks for reporting, will improve on Tildes expansion.

victorskl commented 3 years ago

Fixed since pip install -U yawsso==0.6.0rc3 If issue still persisting, please reopen.