-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
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 | ||
|