generated from Azure/terraform-azurerm-avm-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
81 lines (75 loc) · 2.89 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
resource "azapi_resource" "address" {
type = "Microsoft.EdgeOrder/addresses@2024-02-01"
body = {
properties = {
addressClassification = "Site"
shippingAddress = {
addressType = "None"
city = var.city
companyName = var.company_name
country = var.country
postalCode = var.postal_code
stateOrProvince = var.state_or_province
streetAddress1 = var.street_address_1
streetAddress2 = var.street_address_2
streetAddress3 = var.street_address_3
zipExtendedCode = var.zip_extended_code
}
contactDetails = {
contactName = var.contact_name
emailList = var.email_list
mobile = var.mobile
phone = var.phone
phoneExtension = var.phone_extension
}
}
}
location = var.location
name = var.address_resource_name
parent_id = var.resource_group_id
}
resource "azapi_resource" "site" {
type = "Microsoft.Edge/Sites@2023-07-01-preview"
body = {
properties = {
displayName = var.site_display_name
addressResourceId = azapi_resource.address.id
provisioningState = null
}
id = null
name = null
systemData = null
type = null
}
name = var.site_resource_name
parent_id = var.resource_group_id
schema_validation_enabled = false
lifecycle {
ignore_changes = [
body.properties.provisioningState,
body.id,
body.name,
body.systemData,
body.type,
]
}
}
# 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.address.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.address.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
}