-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvnet.tf
64 lines (57 loc) · 2.54 KB
/
vnet.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
resource "azurerm_virtual_network" "hub" {
name = var.hub
resource_group_name = azurerm_resource_group.hub.name
location = azurerm_resource_group.hub.location
tags = azurerm_resource_group.hub.tags
address_space = var.hub_vnet_address_space
}
resource "azurerm_subnet" "SharedServices" {
depends_on = [azurerm_virtual_network.hub]
name = "SharedServices"
resource_group_name = azurerm_resource_group.hub.name
virtual_network_name = azurerm_virtual_network.hub.name
address_prefixes = [
cidrsubnet(azurerm_virtual_network.hub.address_space[0], 2, 0),
// cidrsubnet(azurerm_virtual_network.hub.address_space[0], 3, 2)
]
}
resource "azurerm_subnet" "DomainControllers" {
depends_on = [azurerm_subnet.SharedServices]
name = "DomainControllers"
resource_group_name = azurerm_resource_group.hub.name
virtual_network_name = azurerm_virtual_network.hub.name
address_prefixes = [cidrsubnet(azurerm_virtual_network.hub.address_space[0], 5, 12)]
}
resource "azurerm_subnet" "AzureFirewallSubnet" {
depends_on = [azurerm_subnet.DomainControllers]
name = "AzureFirewallSubnet" # Minimum /26
resource_group_name = azurerm_resource_group.hub.name
virtual_network_name = azurerm_virtual_network.hub.name
address_prefixes = [cidrsubnet(azurerm_virtual_network.hub.address_space[0], 2, 2)]
}
resource "azurerm_subnet" "AzureBastionSubnet" {
depends_on = [azurerm_subnet.AzureFirewallSubnet]
name = "AzureBastionSubnet" # Minimum /27
resource_group_name = azurerm_resource_group.hub.name
virtual_network_name = azurerm_virtual_network.hub.name
address_prefixes = [cidrsubnet(azurerm_virtual_network.hub.address_space[0], 3, 6)]
}
resource "azurerm_subnet" "GatewaySubnet" {
depends_on = [azurerm_subnet.AzureBastionSubnet]
name = "GatewaySubnet" # Minimum /27
resource_group_name = azurerm_resource_group.hub.name
virtual_network_name = azurerm_virtual_network.hub.name
address_prefixes = [cidrsubnet(azurerm_virtual_network.hub.address_space[0], 3, 7)]
}
output "vnet" {
value = azurerm_virtual_network.hub
}
output "subnet" {
value = {
"SharedServices" = azurerm_subnet.SharedServices
"DomainControllers" = azurerm_subnet.DomainControllers
"AzureFirewallSubnet" = azurerm_subnet.AzureFirewallSubnet
"AzureBastionSubnet" = azurerm_subnet.AzureBastionSubnet
"GatewaySubnet" = azurerm_subnet.GatewaySubnet
}
}