-
Notifications
You must be signed in to change notification settings - Fork 1
/
nic.tf
126 lines (102 loc) · 4.43 KB
/
nic.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
resource "azurerm_network_security_group" "manager_sg" {
name = "${var.resource_group_name}_manager_sg"
location = var.resource_group_location
resource_group_name = var.resource_group_name
security_rule {
name = "AllowInboundHTTP"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "80"
source_address_prefix = "*"
destination_address_prefix = "*"
}
security_rule {
name = "AllowInboundHTTPS"
priority = 120
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "*"
destination_address_prefix = "*"
}
}
resource "azurerm_network_security_group" "worker_sg" {
name = "${var.resource_group_name}_worker_sg"
location = var.resource_group_location
resource_group_name = var.resource_group_name
}
resource "azurerm_network_security_group" "manual_sg" {
name = "${var.resource_group_name}_manual_sg"
location = var.resource_group_location
resource_group_name = var.resource_group_name
}
resource "azurerm_network_interface" "manual_nic" {
count = var.manual_instance_count
name = "${var.resource_group_name}_manual_nic-${count.index}"
location = var.resource_group_location
resource_group_name = var.resource_group_name
ip_configuration {
name = "manual_ipconfig-${count.index}"
subnet_id = azurerm_subnet.subnet_internal.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_network_interface" "manager_nic" {
count = var.manager_instance_count
name = "${var.resource_group_name}_manager_nic-${count.index}"
location = var.resource_group_location
resource_group_name = var.resource_group_name
ip_configuration {
name = "manager_ipconfig-${count.index}"
subnet_id = azurerm_subnet.subnet_internal.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = "${count.index == 0 ? azurerm_public_ip.public_ip.id : null}"
}
}
resource "azurerm_network_interface" "worker_nic" {
count = var.worker_instance_count
name = "${var.resource_group_name}_worker_nic-${count.index}"
location = var.resource_group_location
resource_group_name = var.resource_group_name
ip_configuration {
name = "worker_ipconfig-${count.index}"
subnet_id = azurerm_subnet.subnet_internal.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_network_interface" "worker_gpu_nic" {
count = var.gpu_instance_count
name = "${var.resource_group_name}_worker_gpu_nic-${count.index}"
location = var.resource_group_location
resource_group_name = var.resource_group_name
ip_configuration {
name = "worker_gpu_ipconfig-${count.index}"
subnet_id = azurerm_subnet.subnet_internal.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_network_interface_security_group_association" "manager_nic_sg_association" {
count = var.manager_instance_count
network_interface_id = azurerm_network_interface.manager_nic[count.index].id
network_security_group_id = azurerm_network_security_group.manager_sg.id
}
resource "azurerm_network_interface_security_group_association" "worker_nic_sg_association" {
count = var.worker_instance_count
network_interface_id = azurerm_network_interface.worker_nic[count.index].id
network_security_group_id = azurerm_network_security_group.worker_sg.id
}
resource "azurerm_network_interface_security_group_association" "worker_gpu_nic_sg_association" {
count = var.gpu_instance_count
network_interface_id = azurerm_network_interface.worker_gpu_nic[count.index].id
network_security_group_id = azurerm_network_security_group.worker_sg.id
}
resource "azurerm_network_interface_security_group_association" "manual_nic_sg_association" {
count = var.manual_instance_count
network_interface_id = azurerm_network_interface.manual_nic[count.index].id
network_security_group_id = azurerm_network_security_group.manual_sg.id
}