Skip to content

Instantly share code, notes, and snippets.

View iamgeef's full-sized avatar

Gareth McShane iamgeef

  • news corp
  • Australia
  • 08:34 (UTC +10:00)
View GitHub Profile
@iamgeef
iamgeef / ak.sh
Last active July 22, 2023 00:48
Refresh AWS STS credentials
#!/bin/bash
## get current sts details
set -e
sts=$(aws sts get-caller-identity --profile $1)
date
echo """Current Identity:
$sts
"""
account=$(echo $sts | jq -r .Arn | awk '{split($0, a, ":"); print a[5]}')
role=$(echo $sts | jq -r .Arn | awk '{split($0, a, ":"); print a[6]}' | awk '{split($0, a, "/"); print a[2]}')