forked from cip-core-mirrors/OCTANE-AZURE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemove-AzureCIAPHosting.ps1
66 lines (50 loc) · 1.79 KB
/
Remove-AzureCIAPHosting.ps1
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<#
.SYNOPSIS
Destroy CIAP hosting stack.
.DESCRIPTION
This script destroes CIAP hosting stack on a target subscription/environment, 1 public ip, 1 Loadbalancer 2 VMs haproxy in frontend , 1 VM admin .
For now referential is managed manually
.PARAMETER Environment
Available deployment environments:
* dev: Automation server (Azure devops)
* hml: Tests & Automation server (Azure devops)
* prd: Production (Azure devops with approvable user)
.PARAMETER Stack
define tag for all VM Azure that are comprised in CIAP hosting stack. vm admin is not concerned.
.EXAMPLE
Run only form pipeline azure devops.
.OUTPUTS
.NOTES
Author: Youcef FETHOUNE & Marouan BELGHITH
Date: 22 07 2019
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $True, Position = 1)]
[ValidateSet("dev", "hml", "prd")]
[string]$Environment,
[Parameter(Mandatory = $True, Position = 2)]
[string]$Stack
)
try
{
#
# DESTROY CIAP HOSTING Instances
#
Write-Host "-----------------------------------------------------------------------------------------------"
cd Instance
terraform destroy -auto-approve -var-file="..\Conf\variables\access.tfvars" -var-file="..\Conf\variables\logs.tfvars" -var-file="..\Conf\variables\variables.tfvars" -var="environment=$($Environment)" -var="stack=$($Stack)"
#
# 3 DESTROY STORAGE ACCOUNT WHICH HOSTS TERRAFORM STATE FILE
#
# destroy backend hosting
Write-Host "-----------------------------------------------------------------------------------------------"
Write-Host "terraform destroy storage acccount which hosts ciap hosting terraform state file"
# go to workspace.
cd ..
}
catch
{
# if any erors then break script and stop all pipelines azure devops.
break
}