^ / 004_aws_helpers
aws cli doesn’t provide an easy way to know if your sso session it still valid.
aws sso auth is used for other systems like kubernetes
these helpers are useful for automatic login when session is expired, e.g. asv || asl && k9s
alias asl='aws sso login'
# is the aws sso token valid
function asv() {
if [ $(ast) = "null" ]; then
echo 'error: aws sso session expired'
return 1
fi
}
# gets the aws sso token
alias ast="cat ~/.aws/sso/cache/* | jq -rs 'map(select(.accessToken and .expiresAt > (now | todate)) | .accessToken)[0]'"