Skip to content

Instantly share code, notes, and snippets.

@SinisterMinister
Created March 10, 2017 18:18
Show Gist options
  • Save SinisterMinister/4cc4b4346d4589b7fb834c7bcfe6d75b to your computer and use it in GitHub Desktop.
Save SinisterMinister/4cc4b4346d4589b7fb834c7bcfe6d75b to your computer and use it in GitHub Desktop.
#################################
# 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