cloud-run-job-base/scripts/deploy/plan_terraform.sh

24 lines
455 B
Bash
Executable File

#!/bin/bash
# Safe mode(when error,kill script)
set -euo pipefail
# 変数の設定({HOME}/hash.txt からハッシュ値を取得)
HASH_SUFFIX=${HASH_SUFFIX}
TF_DIR=${TF_DIR:-terraform}
ENV=${ENV:-dev}
cd "$TF_DIR"
if [ -f "${ENV}.tfvars" ]; then
terraform plan \
-out=tfplan \
-var-file="${ENV}.tfvars" \
-var="hash_suffix=${HASH_SUFFIX}"
else
# error raise
echo "ERROR: ${ENV}.tfvars not found in $(pwd)" >&2
exit 1
fi