Created
July 2, 2019 17:14
-
-
Save keymon/f0f8cf8ed386d69fa0d41b11eb42a3be to your computer and use it in GitHub Desktop.
Check date of AWS token in bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| get_token_ttl() { | |
| if [ -n "${AWS_CREDENTIAL_EXPIRE}" ]; then | |
| if date --version 2>&1 | grep -q GNU; then | |
| token_epoch="$(date -d "${AWS_CREDENTIAL_EXPIRE}" +%s)" | |
| elif date --version 2>&1 | grep -q ymwdHMS; then | |
| token_epoch="$(date -j -u -f '%Y-%m-%dT%H:%M:%SZ' "${AWS_CREDENTIAL_EXPIRE}" +%s)" | |
| fi | |
| current_epoch="$(date +%s)" | |
| echo "$(( token_epoch - current_epoch ))" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment