Build script that doesnt totally suck IG

This commit is contained in:
shockrah 2024-06-24 20:44:21 -07:00
parent b6e3010126
commit fb2350077e
2 changed files with 21 additions and 29 deletions

View File

@ -1,24 +0,0 @@
plan=out.plan
SHELL := /bin/bash
$(plan): *.tf
source ./secrets.sh && terraform plan -var-file variables.tfvars -input=false -out $(plan)
push: build
source ./secrets.sh && terraform apply $(plan)
refresh:
source ./secrets.sh && terraform apply -refresh-only
test:
terraform validate
rip:
source ./secrets.sh && terraform plan -destroy -var-file variables.tfvars -input=false -out $(plan)
clean:
rm -f $(plan)
.PHONY: test build clean push rip

View File

@ -2,14 +2,30 @@
set -e set -e
plan=out.plan opt=$1
plan=tfplan
refresh=$1 build_plan() {
echo Generating plan
plan() {
set -x set -x
terraform plan -var-file variables.tfvars -input=false -out $plan terraform plan -var-file variables.tfvars -input=false -out $plan
} }
[[ -z "$refresh " ]] && plan || source ./secrets.sh && plan deploy_plan() {
echo deploy
}
help_prompt() {
cat <<- EOF
Options: plan deploy help
EOF
}
# Default to building a plan
source ./secrets.sh
case $opt in
plan) build_plan;;
deploy) deploy_plan;;
*) help_prompt;;
esac