Created
March 10, 2017 18:18
-
-
Save SinisterMinister/4cc4b4346d4589b7fb834c7bcfe6d75b 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
################################# | |
# Functions # | |
################################# | |
function aws { | |
/usr/local/bin/aws "$@" | ppj | |
} | |
function ppj { | |
pygmentize -f terminal256 -l json -O style=monokai | |
} | |
function gen_keys { | |
if [ -z "$1" ] | |
then | |
read -p "Enter AWS account number: " | |
else | |
acct=$1 | |
fi | |
if [ -z "$2" ] | |
then | |
read -p "Enter AWS UserName: " username | |
else | |
username=$2 | |
fi | |
if [ -z "$3" ] | |
then | |
read -p "Enter MFA Token: " token | |
else | |
token=$3 | |
fi | |
creds=$(/usr/local/bin/aws sts get-session-token --serial-number arn:aws:iam::$acct:mfa/$username --token-code $token --profile init --duration-seconds=43200 --output text | awk '{print $2 " " $4 " " $5}' ) | |
read access secret session <<<$creds | |
export AWS_ACCESS_KEY_ID=$access | |
export AWS_SECRET_ACCESS_KEY=$secret | |
export AWS_SESSION_TOKEN=$session | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment