Add Linux and macOS execution commands
Some checks failed
Repo Quality / structure (push) Has been cancelled
Some checks failed
Repo Quality / structure (push) Has been cancelled
This commit is contained in:
23
scripts/validate-terraform.sh
Normal file
23
scripts/validate-terraform.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ENVIRONMENT="${1:-demo}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
TF_DIR="$REPO_ROOT/terraform/envs/$ENVIRONMENT"
|
||||
|
||||
if [[ ! -d "$TF_DIR" ]]; then
|
||||
echo "Terraform environment not found: $TF_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v terraform >/dev/null 2>&1; then
|
||||
echo "Terraform is not installed or not in PATH. Install Terraform 1.6+ and rerun this script." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$TF_DIR"
|
||||
terraform fmt -recursive -check
|
||||
terraform init -backend=false
|
||||
terraform validate
|
||||
|
||||
Reference in New Issue
Block a user