-
Notifications
You must be signed in to change notification settings - Fork 132
/
vnet_transit.tf
100 lines (88 loc) · 4.01 KB
/
vnet_transit.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
resource "azurerm_virtual_network" "transit_vnet" {
name = "${local.prefix}-transit-vnet"
location = azurerm_resource_group.transit_rg.location
resource_group_name = azurerm_resource_group.transit_rg.name
address_space = [var.cidr_transit]
tags = local.tags
}
resource "azurerm_network_security_group" "transit_sg" {
name = "${local.prefix}-transit-nsg"
location = azurerm_resource_group.transit_rg.location
resource_group_name = azurerm_resource_group.transit_rg.name
tags = local.tags
}
resource "azurerm_network_security_rule" "transit_aad" {
name = "AllowAAD-transit"
priority = 200
direction = "Outbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "VirtualNetwork"
destination_address_prefix = "AzureActiveDirectory"
resource_group_name = azurerm_resource_group.transit_rg.name
network_security_group_name = azurerm_network_security_group.transit_sg.name
}
resource "azurerm_network_security_rule" "transit_azfrontdoor" {
name = "AllowAzureFrontDoor-transit"
priority = 201
direction = "Outbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "VirtualNetwork"
destination_address_prefix = "AzureFrontDoor.Frontend"
resource_group_name = azurerm_resource_group.transit_rg.name
network_security_group_name = azurerm_network_security_group.transit_sg.name
}
resource "azurerm_subnet" "transit_public" {
name = "${local.prefix}-transit-public"
resource_group_name = azurerm_resource_group.transit_rg.name
virtual_network_name = azurerm_virtual_network.transit_vnet.name
address_prefixes = [cidrsubnet(var.cidr_transit, 6, 0)]
delegation {
name = "databricks"
service_delegation {
name = "Microsoft.Databricks/workspaces"
actions = [
"Microsoft.Network/virtualNetworks/subnets/join/action",
"Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action",
"Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action"]
}
}
}
resource "azurerm_subnet_network_security_group_association" "transit_public" {
subnet_id = azurerm_subnet.transit_public.id
network_security_group_id = azurerm_network_security_group.transit_sg.id
}
resource "azurerm_subnet" "transit_private" {
name = "${local.prefix}-transit-private"
resource_group_name = azurerm_resource_group.transit_rg.name
virtual_network_name = azurerm_virtual_network.transit_vnet.name
address_prefixes = [cidrsubnet(var.cidr_transit, 6, 1)]
private_endpoint_network_policies = "Enabled"
delegation {
name = "databricks"
service_delegation {
name = "Microsoft.Databricks/workspaces"
actions = [
"Microsoft.Network/virtualNetworks/subnets/join/action",
"Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action",
"Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action"]
}
}
service_endpoints = var.transit_private_subnet_endpoints
}
resource "azurerm_subnet_network_security_group_association" "transit_private" {
subnet_id = azurerm_subnet.transit_private.id
network_security_group_id = azurerm_network_security_group.transit_sg.id
}
resource "azurerm_subnet" "transit_plsubnet" {
name = "${local.prefix}-transit-privatelink"
resource_group_name = azurerm_resource_group.transit_rg.name
virtual_network_name = azurerm_virtual_network.transit_vnet.name
address_prefixes = [cidrsubnet(var.cidr_transit, 6, 2)]
private_endpoint_network_policies = "Enabled"
}