-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubnet.tf
58 lines (57 loc) · 2.46 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
resource "azurerm_network_security_group" "private_nsg" {
name = "private_nsg"
location = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.location
resource_group_name = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.name
security_rule {
name = "block-all-in"
priority = 100
direction = "Inbound"
access = "Deny"
protocol = "*"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
}
security_rule {
name = "block-all-out"
priority = 101
direction = "Outbound"
access = "Deny"
protocol = "*"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
}
}
resource "azurerm_subnet_network_security_group_association" "external_subnet_association" {
subnet_id = azurerm_subnet.external_subnet.id
network_security_group_id = azurerm_network_security_group.private_nsg.id
}
resource "azurerm_subnet_network_security_group_association" "dmz_subnet_association" {
subnet_id = azurerm_subnet.dmz_subnet.id
network_security_group_id = azurerm_network_security_group.private_nsg.id
}
resource "azurerm_subnet_network_security_group_association" "internal_subnet_association" {
subnet_id = azurerm_subnet.internal_subnet.id
network_security_group_id = azurerm_network_security_group.private_nsg.id
}
resource "azurerm_subnet" "external_subnet" {
address_prefixes = [var.external-Prefix]
name = var.external-Name
resource_group_name = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.name
virtual_network_name = azurerm_virtual_network.vnet.name
}
resource "azurerm_subnet" "dmz_subnet" {
address_prefixes = [var.dmz-Prefix]
name = var.dmz-Name
resource_group_name = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.name
virtual_network_name = azurerm_virtual_network.vnet.name
}
resource "azurerm_subnet" "internal_subnet" {
address_prefixes = [var.internal-Prefix]
name = var.internal-Name
resource_group_name = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.name
virtual_network_name = azurerm_virtual_network.vnet.name
}