generated from cyber-scot/terraform-module-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
50 lines (42 loc) · 1.66 KB
/
main.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
resource "azurerm_network_security_group" "nsg" {
name = var.nsg_name
location = var.location
resource_group_name = var.rg_name
tags = var.tags
timeouts {
create = "5m"
delete = "10m"
}
}
resource "azurerm_network_interface_security_group_association" "this" {
count = var.associate_with_nic && var.nic_id != null ? 1 : 0
network_interface_id = var.nic_id
network_security_group_id = azurerm_network_security_group.nsg.id
timeouts {
create = "5m"
delete = "10m"
}
}
resource "azurerm_subnet_network_security_group_association" "this" {
count = var.associate_with_subnet == true ? 1 : 0
subnet_id = var.subnet_id
network_security_group_id = azurerm_network_security_group.nsg.id
timeouts {
create = "5m"
delete = "10m"
}
}
resource "azurerm_network_security_rule" "rules" {
for_each = local.final_nsg_rules
name = each.key
priority = each.value.priority
direction = each.value.direction
access = each.value.access
protocol = each.value.protocol
source_port_range = each.value.source_port_range
destination_port_range = each.value.destination_port_range
source_address_prefix = each.value.source_address_prefix
destination_address_prefix = each.value.destination_address_prefix
resource_group_name = azurerm_network_security_group.nsg.resource_group_name
network_security_group_name = azurerm_network_security_group.nsg.name
}