-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathr-network.tf
More file actions
51 lines (39 loc) · 1.63 KB
/
Copy pathr-network.tf
File metadata and controls
51 lines (39 loc) · 1.63 KB
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
locals {
network_interface_ids = concat(
azurerm_network_interface.this[*].id,
(var.network_interface_ids != null ? var.network_interface_ids : [])
)
network_security_group_id = var.network_security_group_id
}
resource "azurerm_network_interface" "this" {
count = var.create_network_interface ? 1 : 0
name = "nic-${trimprefix(var.name, "vm-")}"
location = var.location
resource_group_name = var.resource_group_name
tags = var.tags
dns_servers = var.dns_servers
accelerated_networking_enabled = var.accelerated_networking_enabled
ip_forwarding_enabled = var.ip_forwarding_enabled
ip_configuration {
name = "ipconfig1"
private_ip_address = var.private_ip_address
private_ip_address_allocation = var.private_ip_address == null ? "Dynamic" : "Static"
public_ip_address_id = one(azurerm_public_ip.this[*].id)
subnet_id = var.subnet_id
}
}
resource "azurerm_network_interface_security_group_association" "this" {
count = var.create_network_interface && var.network_security_group_id != null ? 1 : 0
network_interface_id = azurerm_network_interface.this[0].id
network_security_group_id = local.network_security_group_id
}
resource "azurerm_public_ip" "this" {
count = var.create_public_ip_address ? 1 : 0
name = "nic-${trimprefix(var.name, "vm-")}"
location = var.location
resource_group_name = var.resource_group_name
tags = var.tags
allocation_method = "Static"
sku = "Standard"
sku_tier = "Regional"
}