common-fate / granted

The easiest way to access your cloud.
https://granted.dev
MIT License
957 stars 90 forks source link

Granted constant session expiry and reassume loop. #547

Closed cameronw-tempo closed 8 months ago

cameronw-tempo commented 8 months ago

Hi all, A big fan of granted, however I've suddenly come across a new problem. It appears to have started after using brew to update yesterday to version 0.20. I can't say for sure which version I was on previously, likely 0.19.2.

My zsh shell constantly reassumes my session with every shell command. Once I have assumed a role, the terminal session will tell me it has expired and attempt to reassume after every command. Even regular shell commands like ls/pwd etc. It also causes a 1-2 second lag before executing the command. It only starts after running "assume".

See an example below.

cw@macbook ~$ ls
granted session expired; reassuming XXXXXXXXXXXX:Developer
.[✔] [XXXXXXXXXXXX:Developer](ap-southeast-2) session credentials ready

I've attempted clearing all my AWS configs and exporting/generating new details but without any success. If anyone is able to help, I would be very grateful! Thanks.

shwethaumashanker commented 8 months ago

A change we made in #467 is causing the ZSH auto-reassume hook to trigger on every command:

assume --region us-west-1 my-profile

# then, immediately after, run another command:
ls
<- granted_auto_reassume zsh function is called immediately here

@cameronw-tempo assuming that you are using the credential_process integration, could you please test switching off the ZSH automatic reassumption hook and let us know if your workflows still work? You can do this by removing the export GRANTED_ENABLE_AUTO_REASSUME=true line from your ~/.zshrc.

The change we made in #467 should negate the need to use the ZSH auto-reassumption hook altogether. We'll update our documentation to clarify this. I'll leave this issue open until we deal with the fact that the hook is being called repeatedly, and also that when the hook is called it doesn't respect the existing AWS_REGION environment variable.

cameronw-tempo commented 8 months ago

Thank you! I've removed the line from the .zshrc and restarted all my shells and the issue no longer occurs. Everything behaves normally now and the reassume process isn't initiated. Thank you for your help.