Also generated tfvars from apps.config.

main
Thomas Hintz 1 week ago
parent 8b967409d0
commit 2a010e03aa

2
.gitignore vendored

@ -17,4 +17,6 @@ app
apps.config
# generated files
all-apps/lb/Caddyfile
generated.tfvars

@ -12,11 +12,14 @@ all-apps/lb/Caddyfile: apps.config make-caddyfile.sh
ignition.json: cl.yaml app/.dirstamp all-apps/lb/Caddyfile
cat cl.yaml | sudo docker run --rm --volume /home/tjhintz/.ssh/id_rsa.pub:/pwd/ssh-keys --volume ${PWD}:/pwd --workdir /pwd -i quay.io/coreos/butane:latest -d /pwd > ignition.json
plan: ignition.json
terraform plan -var-file $(TERRAFORM_ENV).tfvars
generated.tfvars: apps.config make-generated.sh
./make-generated.sh > generated.tfvars
apply: ignition.json
terraform apply -var-file $(TERRAFORM_ENV).tfvars
plan: ignition.json $(TERRAFORM_ENV).tfvars generated.tfvars
bash -c "terraform plan -var-file=<(cat $(TERRAFORM_ENV).tfvars generated.tfvars)"
apply: ignition.json $(TERRAFORM_ENV).tfvars generated.tfvars
bash -c "terraform apply -var-file=<(cat $(TERRAFORM_ENV).tfvars generated.tfvars)"
## to help me remember the command to run to test the config locally
testlocalhost:

@ -0,0 +1,40 @@
#!/bin/bash
# this script generates the shared values for the
# terraform config (domain & subdomain variables)
# it depends on apps.config which should define:
# ROOT_DOMAIN - the root domain for all apps
# APP_CONFIGS - app-subdomain pairs, configured via a comma, like:
# app1,subdomain1 app2,subdomain2 app3,subdomain3
# full example:
# ROOT_DOMAIN=nassella.cc
# APP_CONFIGS="app1,subdomain1 app2,subdomain2 app3,subdomain3"
set -e
. apps.config
read -r -a APP_CONFIGS <<< "$APP_CONFIGS"
APP_CONFIGS+=('lb,root')
echo "domain = \"$ROOT_DOMAIN\""
echo -n "subdomains = ["
separator=''
for config_string in ${APP_CONFIGS[@]}; do
IFS=','
read -r -a config <<< "$config_string"
subdomain=${config[1]}
echo -n "$separator"
echo -n "\"$subdomain\""
separator=', '
done
echo "]"
Loading…
Cancel
Save