-
Notifications
You must be signed in to change notification settings - Fork 3
/
netsec.tf
executable file
·36 lines (34 loc) · 1.41 KB
/
netsec.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
# Create Network Security Group and rule
resource "azurerm_network_security_group" "myterraformnsg" {
name = "SecurityGroup"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
}
# Security Rule for SSH access
resource "azurerm_network_security_rule" "inbound_ssh" {
name = "SSH"
priority = 1001
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "22"
source_address_prefix = var.ssh-allowed-ip
destination_address_prefix = "*"
resource_group_name = azurerm_resource_group.rg.name
network_security_group_name = azurerm_network_security_group.myterraformnsg.name
}
# Security Rule for port 443 and 80
resource "azurerm_network_security_rule" "inbound_traffic" {
name = "Inbound80_443"
priority = 1002
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_ranges = ["80", "443"]
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = azurerm_resource_group.rg.name
network_security_group_name = azurerm_network_security_group.myterraformnsg.name
}