-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.tf
42 lines (36 loc) · 1.62 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
resource "azurerm_virtual_network" "vnet" {
name = var.name
resource_group_name = var.resource_group_name
location = var.location
tags = var.tags
address_space = var.address_space
dns_servers = var.dns_servers
bgp_community = var.bgp_community
dynamic "ddos_protection_plan" {
for_each = var.ddos_protection_plan_id != null ? [""] : []
content {
id = var.ddos_protection_plan_id
enable = true
}
}
}
resource "azurerm_subnet" "subnets" {
for_each = { for subnet in var.subnets : subnet.name => subnet }
name = each.value.name
resource_group_name = azurerm_virtual_network.vnet.resource_group_name
virtual_network_name = azurerm_virtual_network.vnet.name
address_prefixes = each.value.address_prefixes
service_endpoints = each.value.service_endpoints
private_endpoint_network_policies_enabled = each.value.private_endpoint_network_policies_enabled
private_link_service_network_policies_enabled = each.value.private_link_service_network_policies_enabled
dynamic "delegation" {
for_each = lookup(each.value, "delegation", null) != null ? [""] : []
content {
name = each.value.delegation
service_delegation {
name = each.value.delegation
actions = formatlist("Microsoft.Network/%s", local.service_delegation_actions[each.value.delegation])
}
}
}
}