Created
November 21, 2018 02:00
-
-
Save royge/a6b123f1a817ba9adde8ca0e24c3fb92 to your computer and use it in GitHub Desktop.
Get new vault AWS dynamic secrets and set environment variables.
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
# Vault config | |
export VAULT_ADDR=http://127.0.0.1:8200 | |
export VAULT_TOKEN=<your-vault-token> | |
TMP_FILE=$(mktemp) | |
# Get new credentials | |
vault read aws/creds/admin > $TMP_FILE | |
# Extract from the output. | |
ACCESS_KEY=$(cat $TMP_FILE | awk '/access_key/ {print $2}') | |
SECRET_KEY=$(cat $TMP_FILE | awk '/secret_key/ {print $2}') | |
rm $TMP_FILE | |
# Set to environment variables. | |
export AWS_ACCESS_KEY_ID=$ACCESS_KEY | |
export AWS_SECRET_ACCESS_KEY=$SECRET_KEY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment