Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions local.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
locals {
nsgrules = {
HTTPS = {
name = "HTTPS"
priority = 1010
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "*"
destination_address_prefix = "*"
}

HTTP = {
name = "HTTP"
priority = 1020
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "80"
source_address_prefix = "*"
destination_address_prefix = "*"
}

SSH = {
name = "SSH"
priority = 1030
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "22"
source_address_prefix = "*"
destination_address_prefix = "*"
}
}
}
29 changes: 28 additions & 1 deletion network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,31 @@ resource "azurerm_network_interface" "cc_tf_nic" {
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.cc_tf_public_ip.id
}
}
}

resource "azurerm_network_security_group" "cc_tf_nsg" {
name = "${var.prefix}-nsg"
location = azurerm_resource_group.cc_tf_rg.location
resource_group_name = azurerm_resource_group.cc_tf_rg.name

}

resource "azurerm_network_security_rule" "cc_tf_nsg_rules" {
for_each = local.nsgrules
name = each.key
direction = each.value.direction
access = each.value.access
priority = each.value.priority
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_resource_group.cc_tf_rg.name
network_security_group_name = azurerm_network_security_group.cc_tf_nsg.name
}

resource "azurerm_network_interface_security_group_association" "cc_tf_nsg_association" {
network_interface_id = azurerm_network_interface.cc_tf_nic.id
network_security_group_id = azurerm_network_security_group.cc_tf_nsg.id
}