-
Notifications
You must be signed in to change notification settings - Fork 0
/
destroy.ps1
19 lines (15 loc) · 992 Bytes
/
destroy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /usr/bin/pwsh
[CmdletBinding()]
Param(
[string]$flavor = "azure",
[string]$tf_workspace = (Invoke-Expression -Command "terraform workspace show").Trim(),
[string]$kube_config_dir = "credentials/workspaces/${tf_workspace}/.kube",
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$Args
)
#Initialize terraform
terraform init flavors/${flavor}
$provider_specific_variable_file=If (Test-Path "customizations/workspaces/${tf_workspace}/provider.tfvars" -PathType Leaf) {"customizations/workspaces/${tf_workspace}/provider.tfvars"} Else {"customizations/provider.tfvars"}
$flavor_variable_file=If (Test-Path "customizations/workspaces/${tf_workspace}/flavorize.tfvars" -PathType Leaf) {"customizations/workspaces/${tf_workspace}/flavorize.tfvars"} Else {"customizations/flavorize.tfvars"}
#Create the terraform plan
terraform destroy -var-file="${provider_specific_variable_file}" -var-file="${flavor_variable_file}" flavors/${flavor}