generated from UKHO/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspoke-subnet.tf
43 lines (39 loc) · 2.27 KB
/
spoke-subnet.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
resource "azurerm_subnet" "spokesubnet" {
count = length(var.subnets)
name = var.subnets[count.index].name
provider = azurerm.src
resource_group_name = var.resource_group.name
virtual_network_name = azurerm_virtual_network.spokevnet.name
address_prefixes = [cidrsubnet(local.base_cidr_block, try(var.subnets[count.index].newbits,var.newbits), var.subnets[count.index].number)]
service_endpoints = try(var.subnets[count.index].service_endpoints, var.service_endpoints)
lifecycle { ignore_changes = [private_endpoint_network_policies] }
}
resource "azurerm_subnet" "spokesubnet_delegated" {
count = length(var.subnets_with_delegation)
name = var.subnets_with_delegation[count.index].name
provider = azurerm.src
resource_group_name = var.resource_group.name
virtual_network_name = azurerm_virtual_network.spokevnet.name
address_prefixes = [cidrsubnet(local.base_cidr_block, try(var.subnets_with_delegation[count.index].newbits,var.newbits), var.subnets_with_delegation[count.index].number)]
service_endpoints = try(var.subnets_with_delegation[count.index].service_endpoints,var.service_endpoints)
delegation {
name = replace(var.subnets_with_delegation[count.index].delegation.name,"/",".")
service_delegation {
name = var.subnets_with_delegation[count.index].delegation.name
actions = try(var.subnets_with_delegation[count.index].delegation.actions, ["Microsoft.Network/virtualNetworks/subnets/action"])
}
}
lifecycle { ignore_changes = [private_endpoint_network_policies] }
}
resource "azurerm_subnet_network_security_group_association" "spokesubnetnsg" {
provider = azurerm.src
count = length(var.subnets)
subnet_id = azurerm_subnet.spokesubnet[count.index].id
network_security_group_id = azurerm_network_security_group.nsg.id
}
resource "azurerm_subnet_network_security_group_association" "spokesubnetdelegatednsg" {
provider = azurerm.src
count = length(var.subnets_with_delegation)
subnet_id = azurerm_subnet.spokesubnet_delegated[count.index].id
network_security_group_id = azurerm_network_security_group.nsg.id
}