Skip to content

Instantly share code, notes, and snippets.

View trallnag's full-sized avatar
🤡

Tim Schwenke trallnag

🤡
  • Bayer AG
  • Wuppertal, Deutschland
View GitHub Profile
@trallnag
trallnag / cached-aws-iam-authenticator
Created October 6, 2024 19:07 — forked from ejhayes/cached-aws-iam-authenticator
Cached STS token for Kubectl on AWS EKS
#!/usr/bin/env bash
CACHE_FILE=${HOME}/.kube/cache/aws-${AWS_PROFILE}.cache
MAXTIME=800
if [ -f $CACHE_FILE ]; then
TS_DB=$(stat -t "%s" ${CACHE_FILE} | cut -d' ' -f10 | tr -d '"')
AGE=$(( `date +%s` - $TS_DB ))
if [[ $AGE -le $MAXTIME ]]; then
cat ${CACHE_FILE}
else
aws "$@" | tee $CACHE_FILE