-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added envrc back into git tracking with chamber modifications
- Loading branch information
1 parent
da269a3
commit 9d7b338
Showing
2 changed files
with
96 additions
and
2 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,96 @@ | ||
#! /usr/bin/env bash | ||
|
||
# DO NOT WRITE SECRETS IN HERE | ||
|
||
# Apache variables | ||
export PROVIDER="org.apache.ws.security.components.crypto.Merlin" | ||
export CLIENT_PROPS_FILE_PATH="src/main/resources/client_sign.properties" | ||
|
||
required_vars=() | ||
var_docs=() | ||
|
||
# Declare an environment variable as required. | ||
# | ||
# require VAR_NAME "Documentation about how to define valid values" | ||
require() { | ||
required_vars+=("$1") | ||
var_docs+=("$2") | ||
} | ||
# Check all variables declared as required. If any are missing, print a message and | ||
# exit with a non-zero status. | ||
check_required_variables() { | ||
missing_var=false | ||
|
||
for i in "${!required_vars[@]}"; do | ||
var=${required_vars[i]} | ||
if [[ -z "${!var:-}" ]]; then | ||
log_status "${var} is not set: ${var_docs[i]}" | ||
missing_var=true | ||
fi | ||
done | ||
|
||
if [[ $missing_var == "true" ]]; then | ||
log_error "Your environment is missing some variables!" | ||
log_error "Set the above variables in .envrc.local and try again." | ||
fi | ||
} | ||
|
||
|
||
|
||
############################# | ||
# AWS VAULT SETTINGS # | ||
############################# | ||
|
||
export AWS_VAULT_KEYCHAIN_NAME=login | ||
|
||
############################# | ||
# Load Secrets from Chamber # | ||
############################# | ||
|
||
# Make Chamber read ~/.aws/config | ||
export AWS_SDK_LOAD_CONFIG=1 | ||
# Make Chamber use the default AWS KMS key | ||
export CHAMBER_KMS_KEY_ALIAS='alias/aws/ssm' | ||
# Make Chamber use path based keys ('/' instead of '.') | ||
export CHAMBER_USE_PATHS=1 | ||
# Sets the number of retries for chamber to 20. | ||
export CHAMBER_RETRIES=20 | ||
|
||
# Loads secrets from chamber instead of requiring them to be listed in .envrc.local | ||
|
||
if [ -e .envrc.chamber ]; then | ||
# Loading secrets from Chamber can take a while. Prevent direnv from | ||
# complaining. | ||
export DIRENV_WARN_TIMEOUT="20s" | ||
|
||
# Evaluate if the files have drifted | ||
if ! cmp .envrc.chamber .envrc.chamber.template >/dev/null 2>&1; then | ||
log_error "Your .envrc.chamber has drifted from .envrc.chamber.template. Please 'cp .envrc.chamber.template .envrc.chamber'" | ||
fi | ||
|
||
source_env .envrc.chamber | ||
else | ||
log_status "Want to load secrets from chamber? 'cp .envrc.chamber.template .envrc.chamber'" | ||
fi | ||
|
||
# Load Keypair Secrets | ||
require TRDM_LAMBDA_MILMOVE_KEYPAIR_BASE64 "See 'DISABLE_AWS_VAULT_WRAPPER=1 AWS_REGION=us-gov-west-1 aws-vault exec transcom-gov-dev -- chamber read trdm-lambda-dev trdm_lambda_milmove_keypair_base64'" | ||
require TRDM_LAMBDA_MILMOVE_KEYPAIR_KEY "See 'DISABLE_AWS_VAULT_WRAPPER=1 AWS_REGION=us-gov-west-1 aws-vault exec transcom-gov-dev -- chamber read trdm-lambda-dev trdm_lambda_milmove_keypair_key'" | ||
require TRDM_LAMBDA_MILMOVE_KEYPAIR_ALIAS "See 'DISABLE_AWS_VAULT_WRAPPER=1 AWS_REGION=us-gov-west-1 aws-vault exec transcom-gov-dev -- chamber read trdm-lambda-dev trdm_lambda_milmove_keypair_alias'" | ||
require TRDM_LAMBDA_MILMOVE_KEYPAIR_TYPE "See 'DISABLE_AWS_VAULT_WRAPPER=1 AWS_REGION=us-gov-west-1 aws-vault exec transcom-gov-dev -- chamber read trdm-lambda-dev trdm_lambda_milmove_keypair_type'" | ||
require TRDM_LAMBDA_MILMOVE_KEYPAIR_FILEPATH "See 'DISABLE_AWS_VAULT_WRAPPER=1 AWS_REGION=us-gov-west-1 aws-vault exec transcom-gov-dev -- chamber read trdm-lambda-dev trdm_lambda_milmove_keypair_filepath'" | ||
|
||
############################################## | ||
# Load Local Overrides and Check Environment # | ||
############################################## | ||
|
||
# Load a local overrides file. Any changes you want to make for your local | ||
# environment should live in that file. | ||
|
||
if [ -e .envrc.local ] | ||
then | ||
source_env .envrc.local | ||
fi | ||
|
||
# Check that all required environment variables are set | ||
check_required_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