-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at adding Honeycomb beeline (#1)
* First pass at adding Honeycomb beeline * Remove refrences to the API Key * feat: adding ability to source secrets from vault * feat: makes the wrapper authenticate to vault The wrapper will now try to loginto vault with the default vault role of hc, get a token and if it can, export the token to the ENV, and start a version of envconsul that will look into vault for the honeycomb api secret. If we aren't running on AWS or the VAULT_TOKEN isn't passed in, start a version that tries to get it's configs from Consul and don't send events to Honeycomb (becasue don't have a API Token)
- Loading branch information
1 parent
9a669e7
commit 75b4ccb
Showing
6 changed files
with
137 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# shellcheck shell=bash | ||
|
||
dotenv | ||
|
||
# auth against Vault if configured | ||
if has vault; then | ||
if [[ "$VAULT_ADDR" && "$VAULT_AUTH_GITHUB_TOKEN" ]]; then | ||
# are we already authenticated? | ||
TOKEN_LOOKUP=$(vault token-lookup -format=json 2>/dev/null) | ||
|
||
if [ "$?" -eq 0 ]; then | ||
# renew if possible | ||
TOKEN_RENEW=$(vault token-renew -format=json 2>/dev/null) | ||
else | ||
# authenticate | ||
vault login -method=github | ||
fi | ||
fi | ||
fi | ||
|
||
function get_vault_kv { | ||
vault_path=$1 | ||
vault_key=${2:-value} | ||
if [[ "$VAULT_ADDR" ]]; then | ||
VAULT_KV=$(curl -s -H "X-Vault-Token: $(cat ~/.vault-token )" -X GET $VAULT_ADDR/v1/${vault_path} | jq -r .data.${vault_key}) | ||
fi | ||
} | ||
|
||
if get_vault_kv "secret/consul" "http_auth"; then | ||
#echo "consul_http_auth = \"${VAULT_KV}\"" > _consul_http_auth.auto.tfvars | ||
export CONSUL_HTTP_AUTH="${VAULT_KV}" | ||
fi | ||
|
||
if get_vault_kv "secret/consul" "http_addr"; then | ||
#echo "consul_http_auth = \"${VAULT_KV}\"" > _consul_http_auth.auto.tfvars | ||
export CONSUL_HTTP_ADDR="${VAULT_KV}" | ||
fi | ||
|
||
# vim: set et fenc=utf-8 ff=unix ft=sh sts=2 sw=2 ts=2 : |
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
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
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
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
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