Skip to content

Commit

Permalink
adds the content
Browse files Browse the repository at this point in the history
  • Loading branch information
hauboldj committed Apr 4, 2016
1 parent 5632f9e commit aba2ae7
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# AWSume: AWS Assume Made Awesome
Utility for easily assuming AWS IAM roles from the command line

## Installation

Copy `awsume` to `/usr/local/bin`

`chmod 700 /usr/local/bin/asume`

`alias awsume='. awsume'`

## Setup

Add profiles to `~/.aws/config`

Add credentials to `~/.aws/credentials`

Usage:

awsume profilename [show]

See our [blog](https://www.trek10.com/blog/awsume-aws-assume-made-awesome) for more details
44 changes: 44 additions & 0 deletions awsume
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

if [[ -z $1 ]];
then
echo Missing profile name
else

aws s3 ls --profile $1 > /dev/null
if [[ $? -eq 0 ]];
then

cachedCreds=`ls ~/.aws/cli/cache/$1*`

token=$(python -c 'import json,sys,fileinput;
obj=json.loads(fileinput.input().readline());
creds = obj["Credentials"]
print creds["SessionToken"] + ""
' $cachedCreds)

id=$(python -c 'import json,sys,fileinput;
obj=json.loads(fileinput.input().readline());
creds = obj["Credentials"]
print creds["AccessKeyId"] + ""
' $cachedCreds)

key=$(python -c 'import json,sys,fileinput;
obj=json.loads(fileinput.input().readline());
creds = obj["Credentials"]
print creds["SecretAccessKey"] + ""
' $cachedCreds)

if [[ "$2" == "show" ]];
then
echo "export AWS_SESSION_TOKEN=$token"
echo "export AWS_SECRET_ACCESS_KEY=$key"
echo "export AWS_ACCESS_KEY_ID=$id"
fi

export AWS_SESSION_TOKEN=$token
export AWS_SECRET_ACCESS_KEY=$key
export AWS_ACCESS_KEY_ID=$id
fi
fi

0 comments on commit aba2ae7

Please sign in to comment.