generated from Azure/terraform-azurerm-avm-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
84 lines (68 loc) · 2.87 KB
/
main.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
data "azapi_resource" "arcbridge" {
type = "Microsoft.ResourceConnector/appliances@2022-10-27"
name = "${var.name}-arcbridge"
parent_id = var.resource_group_id
depends_on = [azapi_update_resource.deploymentsetting]
}
data "azapi_resource" "customlocation" {
type = "Microsoft.ExtendedLocation/customLocations@2021-08-15"
name = var.custom_location_name
parent_id = var.resource_group_id
depends_on = [azapi_update_resource.deploymentsetting]
}
data "azapi_resource_list" "user_storages" {
parent_id = var.resource_group_id
type = "Microsoft.AzureStackHCI/storagecontainers@2022-12-15-preview"
response_export_values = ["*"]
depends_on = [azapi_update_resource.deploymentsetting]
}
data "azapi_resource" "arc_settings" {
type = "Microsoft.AzureStackHCI/clusters/ArcSettings@2024-04-01"
name = "default"
parent_id = azapi_resource.cluster.id
depends_on = [azapi_update_resource.deploymentsetting]
}
resource "azapi_resource" "cluster" {
type = "Microsoft.AzureStackHCI/clusters@2024-01-01"
body = {
properties = {}
}
location = var.location
name = var.name
parent_id = var.resource_group_id
tags = var.cluster_tags
identity {
type = "SystemAssigned"
}
depends_on = [azurerm_role_assignment.service_principal_role_assign]
lifecycle {
ignore_changes = [
body.properties,
identity[0]
]
}
}
# Generate random integer suffix for storage account and key vault
resource "random_integer" "random_suffix" {
max = 99
min = 10
}
# required AVM resources interfaces
resource "azurerm_management_lock" "this" {
count = var.lock != null ? 1 : 0
lock_level = var.lock.kind
name = coalesce(var.lock.name, "lock-${var.lock.kind}")
scope = azapi_resource.cluster.id
notes = var.lock.kind == "CanNotDelete" ? "Cannot delete the resource or its child resources." : "Cannot delete or modify the resource or its child resources."
}
resource "azurerm_role_assignment" "this" {
for_each = var.role_assignments
principal_id = each.value.principal_id
scope = azapi_resource.cluster.id
condition = each.value.condition
condition_version = each.value.condition_version
delegated_managed_identity_resource_id = each.value.delegated_managed_identity_resource_id
role_definition_id = strcontains(lower(each.value.role_definition_id_or_name), lower(local.role_definition_resource_substring)) ? each.value.role_definition_id_or_name : null
role_definition_name = strcontains(lower(each.value.role_definition_id_or_name), lower(local.role_definition_resource_substring)) ? null : each.value.role_definition_id_or_name
skip_service_principal_aad_check = each.value.skip_service_principal_aad_check
}