28 lines
602 B
PowerShell
28 lines
602 B
PowerShell
param(
|
|
[string]$Environment = "demo"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = Split-Path -Parent $PSScriptRoot
|
|
$tfDir = Join-Path $repoRoot "terraform/envs/$Environment"
|
|
|
|
if (-not (Test-Path $tfDir)) {
|
|
throw "Terraform environment not found: $tfDir"
|
|
}
|
|
|
|
$terraform = Get-Command terraform -ErrorAction SilentlyContinue
|
|
if ($null -eq $terraform) {
|
|
throw "Terraform is not installed or not in PATH. Install Terraform 1.6+ and rerun this script."
|
|
}
|
|
|
|
Push-Location $tfDir
|
|
try {
|
|
terraform fmt -recursive -check
|
|
terraform init -backend=false
|
|
terraform validate
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|