-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwebapp-nsg.tf
67 lines (59 loc) · 2.06 KB
/
webapp-nsg.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
resource "azurerm_network_security_group" "webapp_nsg" {
name = "${var.prefix}-webapp-nsg"
location = var.location
resource_group_name = azurerm_resource_group.rg.name
security_rule {
name = "SSH"
priority = 1001
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "22"
source_address_prefix = "*"
destination_address_prefix = "*"
}
security_rule {
name = "Webapp"
priority = 1002
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "5000"
source_address_prefix = "*"
destination_address_prefix = "*"
}
security_rule {
name = "MySQL"
priority = 1003
direction = "Outbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "3306"
source_address_prefix = "*"
destination_address_prefix = "*"
}
tags = {
owner = var.owner
}
}
resource "azurerm_network_interface" "webapp_nic" {
name = "${var.prefix}-webapp-nic"
location = var.location
resource_group_name = azurerm_resource_group.rg.name
ip_configuration {
name = "${var.prefix}-webapp-nic"
subnet_id = azurerm_subnet.subnet.id
private_ip_address_allocation = "dynamic"
public_ip_address_id = azurerm_public_ip.webapp_ip.id
}
tags = {
owner = var.owner
}
}
resource "azurerm_network_interface_security_group_association" "webapp_nic_nsg" {
network_interface_id = azurerm_network_interface.webapp_nic.id
network_security_group_id = azurerm_network_security_group.webapp_nsg.id
}