79269230

Date: 2024-12-10 17:51:05
Score: 1
Natty:
Report link

Use the output from configure export-credentials to find the session expiration. This works for profiles that use a sso-session whereas aws configure get x_security_token_expires does not.

Example

expires=$(aws configure export-credentials | jq -r '.Expiration')
echo "current session expires: $expires"

I've incorporated the above into a gist that configures shell completions for activating AWS_PROFILE and optionally refreshes its sso-session (if it expires in 2 hours or less). See https://gist.github.com/briceburg/f9b485dc0fa75fac0b2b169652e422b3

Reasons:
  • Contains signature (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: briceburg