Skip to content

Instantly share code, notes, and snippets.

@sebastianrothbucher
Created May 31, 2024 14:38
Show Gist options
  • Save sebastianrothbucher/fe4f2790e1a367b65cbd3839c9aa1d6a to your computer and use it in GitHub Desktop.
Save sebastianrothbucher/fe4f2790e1a367b65cbd3839c9aa1d6a to your computer and use it in GitHub Desktop.
STS assume role and export creds - use via . shell-helper.inc in bash
function assumeRoleAndExport {
local STS_RES=$(aws sts assume-role --role-arn $1 --role-session-name "whatever-session-$(uuidgen)")
export AWS_ACCESS_KEY_ID=$(echo $STS_RES | jq -r .Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $STS_RES | jq -r .Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $STS_RES | jq -r .Credentials.SessionToken)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment