-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity.tf
More file actions
43 lines (32 loc) · 1.27 KB
/
security.tf
File metadata and controls
43 lines (32 loc) · 1.27 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
resource "azurerm_network_security_group" "server_nsg" {
name = "server_nsg"
location = var.location
resource_group_name = var.azurerm_resource_group.name
security_rule {
name = "server_inbound"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*" ##You can replace this part with your own IP if you don't want it exposed to public
destination_address_prefix = "*"
}
security_rule {
name = "server_outbound"
priority = 101
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
}
}
/// Associate the Security group to the VM's NIC
resource "azurerm_network_interface_security_group_association" "sec_nic_assiociate" {
network_interface_id = azurerm_network_interface.server-nic.id
network_security_group_id = azurerm_network_security_group.server_nsg.id
}