Skip to content

Instantly share code, notes, and snippets.

@lrvick

lrvick/aws-set-creds.sh

Last active Apr 13, 2020
Embed
What would you like to do?
Decrypt and format downloaded+gpg encrypted amazon credentials file to ramfile and export to current shell.
#!/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
You can’t perform that action at this time.