Last active
September 6, 2015 20:11
-
-
Save etipton/4cc4a5e6146b092dafe7 to your computer and use it in GitHub Desktop.
Convert downloaded AWS access creds to env vars
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
#!/usr/bin/env ruby | |
# Use ENV var if needed, e.g. ".zshenv" | |
shell_init_file = File.expand_path(ENV['SHELL_INIT_FILE'] || '~/.bash_profile') | |
aws_creds_file = File.expand_path(ENV['CREDS_FILE'] || '~/Downloads/credentials.csv') | |
require 'csv' | |
csv = CSV.parse(File.read(aws_creds_file), headers: true) | |
row = csv.first.to_hash | |
File.open(shell_init_file, 'a') do |f| | |
f.write ["", | |
"export AWS_ACCESS_KEY_ID=#{row['Access Key Id']}", | |
"export AWS_SECRET_ACCESS_KEY=#{row['Secret Access Key']}" | |
].join("\n") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment