Complete the code to create a Network Security Group (NSG) resource in Azure.
resource "azurerm_network_security_group" "example" { name = "example-nsg" location = "eastus" resource_group_name = "example-rg" [1] = {} }
The tags block is used to add metadata to the NSG resource. The other options are either incorrect or used elsewhere.
Complete the code to define an inbound security rule allowing HTTP traffic on port 80.
resource "azurerm_network_security_group" "example" { name = "example-nsg" location = "eastus" resource_group_name = "example-rg" security_rule { name = "Allow-HTTP" priority = 100 direction = "Inbound" access = "Allow" protocol = "[1]" source_port_range = "*" destination_port_range = "80" source_address_prefix = "*" destination_address_prefix = "*" } }
The protocol for HTTP traffic is tcp. UDP and ICMP are different protocols, and '*' means all protocols which is not specific.
Fix the error in the security rule to correctly block SSH traffic on port 22.
security_rule {
name = "Deny-SSH"
priority = 200
direction = "Inbound"
access = "[1]"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "22"
source_address_prefix = "*"
destination_address_prefix = "*"
}The correct value to block traffic is Deny. 'Allow' permits traffic, while 'Block' and 'Reject' are invalid in this context.
Fill both blanks to create a security rule that allows inbound HTTPS traffic on port 443 from a specific IP range.
security_rule {
name = "Allow-HTTPS"
priority = 150
direction = "Inbound"
access = "[1]"
protocol = "[2]"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "192.168.1.0/24"
destination_address_prefix = "*"
}The rule should Allow traffic and use the tcp protocol for HTTPS.
Fill all three blanks to define a security rule that denies outbound traffic on all ports and protocols.
security_rule {
name = "Deny-All-Outbound"
priority = 300
direction = "[1]"
access = "[2]"
protocol = "[3]"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
}The rule denies Outbound traffic on all protocols (*) by setting access to Deny.