awscli-login
awscli-login copied to clipboard
Hooks or some cached copy of get-caller-identity
Hello. I'm trying to set up shell prompt integration so that I can see which AWS role I am currently authenticated as on my prompt.
I can get pretty close by using the result of aws get-caller-identity
but that is a pretty slow operation to invoke over and over every time my prompt displays.
I'm wondering if there could be a hook script of some sorts on login / logout so I could know when I need to update? Or alternatively if the get-caller-identity response data could be stored in the ~/.aws-login
folder somewhere for me?
I did find a work around as long as the tool forces you to log out before logging in again
aws_prompt_info() {
local PID_FILE=~/.aws-login/default.pid
local IDENTITY_FILE=~/.aws-login/identity.txt
local FILTER_FILE=~/.oh-my-zsh/custom/aws_filter.jq
local PROF=""
if [[ -f "$PID_FILE" ]] then
PROF=$( cat $IDENTITY_FILE 2>/dev/null || aws sts get-caller-identity | jq -r -f $FILTER_FILE | tee $IDENTITY_FILE)
[[ -n "$PROF" ]] && echo "[$PROF]"
else
[[ -f "$IDENTITY_FILE" ]] && rm $IDENTITY_FILE
fi
}
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.