-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines-destroy.yml
48 lines (42 loc) · 2.1 KB
/
azure-pipelines-destroy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Terraform pipeline
trigger: none
variables:
tf_version: "latest" # what version of terraform should be used
tf_state_rg: "rg-tfstate" # name of the resource group to create/use for the terraform state file
tz_state_location: "uksouth" # location of the resource group to create/use for the terraform state file
tf_state_sku: "Standard_RAGRS" # sku to use when creating the storeage account to create/use for the terraform state file
tf_state_sa_name: "tfstatesa20210606" # name of of the storage account to create/use for the terraform state file
tf_state_container_name: "tfstate" # name of of the container to create/use for the terraform state file
tf_environment: "dev" # enviroment name, used for the statefile name
cost_increase_alert_percentage: 50 # if the difference in costs is higher than x% then you will need to manually validate the deployment
pool:
vmImage: "ubuntu-latest"
stages:
- stage: "TerraformDestroy"
displayName: "Terraform - Destroy"
jobs:
- job: "TerraformDestroy"
displayName: "Terraform > install, init & destroy"
steps:
- task: TerraformInstaller@0
inputs:
terraformVersion: "$(tf_version)"
displayName: "Install > terraform"
- task: TerraformCLI@0
inputs:
command: "init"
backendType: "azurerm"
backendServiceArm: "$(SUBSCRIPTION_NAME)"
ensureBackend: true
backendAzureRmResourceGroupName: "$(tf_environment)-$(tf_state_rg)"
backendAzureRmResourceGroupLocation: "$(tz_state_location)"
backendAzureRmStorageAccountName: "$(tf_state_sa_name)"
backendAzureRmStorageAccountSku: "$(tf_state_sku)"
backendAzureRmContainerName: $(tf_state_container_name)
backendAzureRmKey: "$(tf_environment).terraform.tstate"
displayName: "Run > terraform init"
- task: TerraformCLI@0
inputs:
command: "destroy"
environmentServiceName: "$(SUBSCRIPTION_NAME)"
displayName: "Run > terraform destroy "