-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
ee9aad5
commit 4b5eb63
Showing
2 changed files
with
43 additions
and
5 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
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,26 @@ | ||
#!/bin/bash | ||
|
||
DURATION="${AWS_ROLE_DURATION:-3600}" | ||
SESSION_NAME="${AWS_ROLE_SESSION_NAME:-`date +%s`}" | ||
EXPORT="${EXPORT:-no}" | ||
|
||
# KST=access*K*ey, *S*ecretkey, session*T*oken | ||
KST=(`aws sts assume-role --role-arn "arn:aws:iam::$AWS_ACCOUNT_ID:role/$AWS_ROLE" \ | ||
--role-session-name "$SESSION_NAME" \ | ||
--duration-seconds $DURATION \ | ||
--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' \ | ||
--output text`) | ||
|
||
if [ "$EXPORT" == "yes" ]; then | ||
echo "" | ||
echo "export AWS_ACCESS_KEY_ID=${KST[0]}" | ||
echo "export AWS_SECRET_ACCESS_KEY=${KST[1]}" | ||
echo "export AWS_SESSION_TOKEN=${KST[2]}" | ||
echo "export AWS_SECURITY_TOKEN=${KST[2]}" | ||
else | ||
echo "" | ||
echo "AWS_ACCESS_KEY_ID=${KST[0]}" | ||
echo "AWS_SECRET_ACCESS_KEY=${KST[1]}" | ||
echo "AWS_SESSION_TOKEN=${KST[2]}" | ||
echo "AWS_SECURITY_TOKEN=${KST[2]}" | ||
fi |