-
Notifications
You must be signed in to change notification settings - Fork 0
/
public_ip.tf
29 lines (27 loc) · 1.22 KB
/
public_ip.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
# Public IPs
resource "azurerm_public_ip" "vm" {
count = var.nodecount
name = "${var.prefix}-public-ip-vm${count.index + 1}"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
allocation_method = "Static"
}
# Network interfaces
resource "azurerm_network_interface" "nic" {
count = var.nodecount
name = "${var.prefix}-interface-vm${count.index + 1}"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
ip_configuration {
name = "${var.prefix}-interface-vm${count.index + 1}-config"
subnet_id = azurerm_subnet.main.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.vm[count.index].id
}
}
# Network interface security group associations
resource "azurerm_network_interface_security_group_association" "nsg-nic" {
count = var.nodecount
network_interface_id = azurerm_network_interface.nic[count.index].id
network_security_group_id = azurerm_network_security_group.main.id
}