This file contains hidden or 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
#!/bin/bash | |
set -e | |
# Using jq command, you can format json to key=value string | |
session=$(aws sts assume-role --role-arn $ARN --role-session-name $USER --query 'Credentials') | |
env_options=$(echo $session | jq -r 'del(.Expiration) | to_entries | map([" ", "AWS_" + (.key | gsub("(?<l>[a-z])(?<f>[A-Z])";.l+"_"+.f)|ascii_upcase), "=", .value] | add) | add') | |
echo $env_options | |
#=> AWS_SECRET_ACCESS_KEY=xxxx AWS_SESSION_TOKEN=yyyy AWS_ACCESS_KEY_ID=zzzz | |
# Execute another aws cli using above credentials |
This file contains hidden or 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
# Run this code in Rails(7 or above) console | |
class Decryptor | |
attr_reader :key_generator, :cookie | |
def initialize(cookie:) | |
@cookie = CGI::unescape(cookie) | |
set_key_generator | |
end | |
def set_sha1 |