#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"

TF_VAR_vultr_api_key="$(cat ./secrets/terraform/vultr-api-key.txt)"
export TF_VAR_vultr_api_key

rm -rf .terraform/
terraform init
PLAN_FILE="./secrets/terraform/plan-files/$(date -Iseconds).tfplan"
terraform plan -out="${PLAN_FILE}"
# shellcheck disable=2162
read -p "Is the above Terraform plan acceptable? Press CTRL+c to cancel."
terraform apply "${PLAN_FILE}"
