Files
Software/artemis-backup-20260614-1920/terraform-pve/run.sh

25 lines
598 B
Bash
Executable File

#!/bin/bash
# How to use this file TF_VAR_vmid_base=3550 TF_VAR_lxc_count=4 ./run.sh apply -auto-approve
set -e
cd "$(dirname "$0")"
# Forward all TF_VAR_* environment variables into the container
TF_VAR_ARGS=""
while IFS='=' read -r name _; do
TF_VAR_ARGS="$TF_VAR_ARGS -e $name"
done < <(env | grep '^TF_VAR_')
case "${1:-plan}" in
init|validate|plan|apply|destroy)
docker compose run --rm $TF_VAR_ARGS terraform "$1" "${@:2}"
;;
shell)
docker compose run --rm $TF_VAR_ARGS terraform sh
;;
*)
echo "Usage: $0 [init|plan|apply|destroy|shell]"
exit 1
;;
esac