Created
July 17, 2024 02:46
-
-
Save psgganesh/94c92857d799890865156f712815511c to your computer and use it in GitHub Desktop.
Shell-shortcuts
This file contains hidden or 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
# Custom functions | |
assume_role() { | |
eval $(aws sts assume-role --role-arn "$1" --role-session-name AWSCLI-Session | jq -c '.' | setawsenv.sh) | |
} | |
# Custom scripts | |
export PATH="$PATH:$HOME/bin" |
This file contains hidden or 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
#!/bin/bash | |
# Reading JSON from stdin | |
read -r JSON | |
# Parsing JSON to get AWS credentials | |
ACCESS_KEY_ID=$(echo "$JSON" | jq -r '.Credentials.AccessKeyId') | |
SECRET_ACCESS_KEY=$(echo "$JSON" | jq -r '.Credentials.SecretAccessKey') | |
SESSION_TOKEN=$(echo "$JSON" | jq -r '.Credentials.SessionToken') | |
# Outputting export commands | |
echo "export AWS_ACCESS_KEY_ID=$ACCESS_KEY_ID" | |
echo "export AWS_SECRET_ACCESS_KEY=$SECRET_ACCESS_KEY" | |
echo "export AWS_SESSION_TOKEN=$SESSION_TOKEN" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment