Last active
April 13, 2020 22:51
-
-
Save lrvick/db1463b7e7a1cd4bad4a95b1dcc283fe to your computer and use it in GitHub Desktop.
Decrypt and format downloaded+gpg encrypted amazon credentials file to ramfile and export to current shell.
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
#!/bin/bash | |
set -e | |
# Usage: source <(aws-set-creds aws-access-keys.example.asc) | |
in_file=${1?} | |
out_file=$(mktemp -p /dev/shm/) | |
creds=$(gpg -d ${in_file} 2>&1) | |
aws_access_key_id=$(printf "$creds" | tail -n1 | cut -d ',' -f1) | |
aws_secret_access_key=$(printf "$creds" | tail -n1 | cut -d ',' -f2 | sed -e 's/\r//g' ) | |
export AWS_SHARED_CREDENTIALS_FILE="${out_file}" | |
aws configure set aws_access_key_id $aws_access_key_id | |
aws configure set aws_secret_access_key ${aws_secret_access_key} | |
echo export AWS_SHARED_CREDENTIALS_FILE="${out_file}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment