Created
February 5, 2023 02:32
-
-
Save andreabedini/ea3b3b8f3dcb1c7fc4f8450b4f5dbdec to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
SESSION_NAME="$USER@$HOST" # or whatever | |
echo "Requesting federation token" | |
TOKEN1=$(aws sts get-federation-token --name "$SESSION_NAME" --policy-arns arn=arn:aws:iam::aws:policy/AdministratorAccess --output json) | |
URL1=$(jq -r '.Credentials | {sessionId:.AccessKeyId,sessionKey:.SecretAccessKey,sessionToken:.SessionToken} | @uri "https://signin.aws.amazon.com/federation?Action=getSigninToken&SessionType=json&Session=\(.)"' <<< "$TOKEN1") | |
echo "Requesting login token" | |
TOKEN2=$(curl --silent $URL1) | |
URL2=$(jq -r '@uri "https://signin.aws.amazon.com/federation?Action=login&Destination=https://console.aws.amazon.com&SigninToken=\(.SigninToken)"' <<< "$TOKEN2") | |
echo "Click this: $URL2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment