Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. become() {
  2. SUPERUSER_ROLE_ARN="insert default role arn here"
  3. role_arn=${role_arn:=$SUPERUSER_ROLE_ARN}
  4.  
  5. tmp_credentials_file=$(mktemp /tmp/deploy-credentials.json.XXX)
  6.  
  7. aws sts assume-role --role-arn "${role_arn}" \
  8. --role-session-name "$(whoami)-$(date +'%Y%m%d%H%M%S')" --output json | jq -r ".Credentials" > "$tmp_credentials_file"
  9.  
  10. export AWS_ACCESS_KEY_ID="$(jq -r ".AccessKeyId" < ${tmp_credentials_file})"
  11. export AWS_SECRET_ACCESS_KEY="$(jq -r ".SecretAccessKey" < ${tmp_credentials_file})"
  12. export AWS_SESSION_TOKEN="$(jq -r ".SessionToken" < ${tmp_credentials_file})"
  13. export AWS_SECURITY_TOKEN="$(jq -r ".SessionToken" < ${tmp_credentials_file})"
  14.  
  15. rm "$tmp_credentials_file"
  16. }
  17.  
  18. unbecome() {
  19. unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SECURITY_TOKEN AWS_SESSION_TOKEN
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement