Skip to content

Instantly share code, notes, and snippets.

@lrvick
Last active April 13, 2020 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrvick/db1463b7e7a1cd4bad4a95b1dcc283fe to your computer and use it in GitHub Desktop.
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.
#!/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