Skip to content

Instantly share code, notes, and snippets.

@jbonachera
jbonachera / aws_assume.sh
Created September 29, 2022 09:44
exports AWS credentials environment variables from STS cli call
aws_assume(){
aws sts assume-role --role-arn $1 --role-session-name debug --duration-seconds 900 | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=" + .AccessKeyId + "; export AWS_SECRET_ACCESS_KEY="+.SecretAccessKey + ";export AWS_SESSION_TOKEN="+.SessionToken'
}
# Usage: eval $(aws_assume arn:aws:iam::${AccountId}:role/${RoleName})

Keybase proof

I hereby claim:

  • I am jbonachera on github.
  • I am jubon (https://keybase.io/jubon) on keybase.
  • I have a public key whose fingerprint is B028 2976 A701 7E2D 60F8 B54A 799C 119A 66AF 218A

To claim this, I am signing this object: