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
#!/bin/bash | |
set -e | |
cd $MODULE_NAME | |
echo "init default.tfstate" | |
terraform init -backend-config="key=default.tfstate" | |
echo "select or create new workspace $WORKSPACE_NAME" | |
terraform workspace select $WORKSPACE_NAME || terraform workspace new $WORKSPACE_NAME |
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
#!/bin/bash | |
set -e | |
cd $MODULE_NAME | |
echo "select or create new workspace $WORKSPACE_NAME" | |
terraform workspace select $WORKSPACE_NAME || terraform workspace new $WORKSPACE_NAME | |
echo "plan with var file ~/terraform_variables/$WORKSPACE_NAME/$MODULE_NAME.tfvars" | |
terraform plan -var-file=~/terraform_variables/$WORKSPACE_NAME/$MODULE_NAME.tfvars -out=$MODULE_NAME.tfplan -input=false |
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
#!/bin/bash | |
set -e | |
cd $MODULE_NAME | |
echo "select or create new workspace $WORKSPACE_NAME" | |
terraform workspace select $WORKSPACE_NAME || terraform workspace new $WORKSPACE_NAME | |
echo "apply with var file ~/terraform_variables/$WORKSPACE_NAME/$MODULE_NAME.tfvars" | |
terraform apply -var-file=~/terraform_variables/$WORKSPACE_NAME/$MODULE_NAME.tfvars -auto-approve |
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
#!/bin/bash | |
function fetch_variables() { | |
workspace_name=$1 | |
module_name=$2 | |
echo $(cat ../config/$workspace_name/$module_name.tfvars | sed '/^$/D' | sed 's/.*/TF_VAR_& /' | tr -d '\n') | |
} |
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
#!/bin/bash | |
function parse_and_test_properties_entries() { | |
prop=$1 | |
if [[ "$prop" == "" || $prop = \#* ]]; then | |
continue | |
fi | |
key="$(cut -d'=' -f1 <<<"$prop")" | |
if [[ $key =~ "-" ]]; then |
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
function fetch_secrets() { | |
workspace_name=$1 | |
module_name=$2 | |
secret_key_for_workspace=$(eval "echo \$SECRET_KEY_$workspace_name") | |
echo $(openssl enc -aes-256-cbc -d -in ../config/$workspace_name/$module_name.tfsecrets.enc -pass pass:$secret_key_for_workspace | sed '/^$/D' | sed 's/.*/TF_VAR_& /' | tr -d '\n') | |
} |
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
#!/bin/bash | |
set -e | |
if [ -z "$SECRET_KEY" ]; then | |
echo "Set a SECRET_KEY for \"$WORKSPACE_NAME\" encryption" | |
exit 1 | |
fi | |
function encrypt_file() { | |
input_file=$1 |
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
#!/bin/bash | |
set -e | |
if [ -z "$SECRET_KEY" ]; then | |
echo "Set a SECRET_KEY for \"$WORKSPACE_NAME\" decryption" | |
exit 1 | |
fi | |
function decrypt_file() { | |
input_file=$1 |
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
#!/bin/bash | |
base_dir="config" | |
for sub_dir in $(find $base_dir -mindepth 1 -maxdepth 1 -type d); do | |
workspace_name=${sub_dir#"$base_dir/"} | |
password_var_name="\$SECRET_KEY_$workspace_name" | |
secret_key_for_workspace=$(eval "echo $password_var_name") | |
if [ -z "$secret_key_for_workspace" ]; then |
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
#!/bin/bash | |
set -e | |
source $(dirname "$0")/functions.sh | |
cd $MODULE_NAME | |
echo "select or create new workspace $WORKSPACE_NAME" | |
terraform workspace select $WORKSPACE_NAME || terraform workspace new $WORKSPACE_NAME |
NewerOlder