generated from Azure/terraform-azurerm-avm-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.addons.tf
191 lines (159 loc) · 5.42 KB
/
main.addons.tf
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#adding sleep wait to handle lag in hcx registration for keys
resource "time_sleep" "wait_60_seconds_hcx" {
create_duration = "60s"
triggers = {
addon = azapi_resource.this_private_cloud.id
}
depends_on = [azapi_resource.this_private_cloud]
}
#####################################################################################################################################
# Deploy and configure the HCX Addon
#####################################################################################################################################
resource "azapi_resource" "hcx_addon" {
for_each = { for k, v in var.addons : k => v if lower(k) == "hcx" }
type = "Microsoft.AVS/privateClouds/addons@2023-09-01"
body = {
properties = {
addonType = "HCX"
offer = lower(each.value.hcx_license_type) == "advanced" ? "VMware MaaS Cloud Provider" : "VMware MaaS Cloud Provider (Enterprise)"
}
}
#Resource Name must match the addonType
name = "HCX"
parent_id = azapi_resource.this_private_cloud.id
timeouts {
create = "4h"
delete = "4h"
}
depends_on = [
azapi_resource.this_private_cloud,
azapi_resource.clusters,
azurerm_role_assignment.this_private_cloud,
azurerm_monitor_diagnostic_setting.this_private_cloud_diags,
#azapi_update_resource.managed_identity,
azapi_update_resource.customer_managed_key
]
#adding lifecycle block to handle replacement issue with parent_id
lifecycle {
ignore_changes = [
parent_id
]
}
}
#adding sleep wait to handle lag in hcx registration for keys
resource "time_sleep" "wait_120_seconds" {
create_duration = "60s"
depends_on = [azapi_resource.hcx_addon]
}
#create the hcx key(s) if defined
resource "azapi_resource" "hcx_keys" {
for_each = toset(try(var.addons.hcx.hcx_key_names, []))
type = "Microsoft.AVS/privateClouds/hcxEnterpriseSites@2023-09-01"
name = each.key
parent_id = azapi_resource.this_private_cloud.id
response_export_values = ["*"]
depends_on = [
time_sleep.wait_120_seconds,
azapi_resource.hcx_addon
]
lifecycle {
ignore_changes = [
parent_id
]
}
}
#####################################################################################################################################
# Deploy and configure the SRM Addon
#####################################################################################################################################
resource "azapi_resource" "srm_addon" {
for_each = { for k, v in var.addons : k => v if lower(k) == "srm" }
type = "Microsoft.AVS/privateClouds/addons@2023-09-01"
body = {
properties = {
addonType = "SRM"
licenseKey = each.value.srm_license_key
}
}
#Resource Name must match the addonType
name = "SRM"
parent_id = azapi_resource.this_private_cloud.id
timeouts {
create = "4h"
delete = "4h"
}
depends_on = [
azapi_resource.this_private_cloud,
azapi_resource.clusters,
azurerm_role_assignment.this_private_cloud,
azurerm_monitor_diagnostic_setting.this_private_cloud_diags,
#azapi_update_resource.managed_identity,
azapi_update_resource.customer_managed_key,
azapi_resource.hcx_addon,
azapi_resource.hcx_keys
]
#adding lifecycle block to handle replacement issue with parent_id
lifecycle {
ignore_changes = [
parent_id
]
}
}
#####################################################################################################################################
# Deploy and configure the VR Addon
#####################################################################################################################################
resource "azapi_resource" "vr_addon" {
for_each = { for k, v in var.addons : k => v if lower(k) == "vr" }
type = "Microsoft.AVS/privateClouds/addons@2023-09-01"
body = {
properties = {
addonType = "VR"
vrsCount = each.value.vr_vrs_count
}
}
#Resource Name must match the addonType
name = "VR"
parent_id = azapi_resource.this_private_cloud.id
timeouts {
create = "4h"
delete = "4h"
}
depends_on = [
azapi_resource.this_private_cloud,
azapi_resource.clusters,
azurerm_role_assignment.this_private_cloud,
azurerm_monitor_diagnostic_setting.this_private_cloud_diags,
#azapi_update_resource.managed_identity,
azapi_update_resource.customer_managed_key,
azapi_resource.hcx_addon,
azapi_resource.hcx_keys,
azapi_resource.srm_addon
]
#adding lifecycle block to handle replacement issue with parent_id
lifecycle {
ignore_changes = [
parent_id
]
}
}
#####################################################################################################################################
# Deploy and configure the ARC Addon
#####################################################################################################################################
resource "azapi_resource" "arc_addon" {
for_each = { for k, v in var.addons : k => v if lower(k) == "arc" }
type = "Microsoft.AVS/privateClouds/addons@2023-09-01"
body = {
properties = {
addonType = "Arc"
vCenter = each.value.arc_vcenter
}
}
#Resource Name must match the addonType
name = "Arc"
parent_id = azapi_resource.this_private_cloud.id
#adding lifecycle block to handle replacement issue with parent_id
lifecycle {
ignore_changes = [
parent_id
]
}
}