Complete the code to specify the port for SSH access in an Azure Network Security Group rule.
resource "azurerm_network_security_rule" "ssh_rule" { name = "SSH" priority = 1001 direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" destination_port_range = "[1]" source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name network_security_group_name = azurerm_network_security_group.nsg.name }
Port 22 is the standard port used for SSH access.
Complete the code to specify the port for RDP access in an Azure Network Security Group rule.
resource "azurerm_network_security_rule" "rdp_rule" { name = "RDP" priority = 1002 direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" destination_port_range = "[1]" source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name network_security_group_name = azurerm_network_security_group.nsg.name }
Port 3389 is the standard port used for RDP access.
Fix the error in the Azure VM SSH access configuration by completing the missing property.
resource "azurerm_linux_virtual_machine" "vm" { name = "myLinuxVM" resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location size = "Standard_B1s" admin_username = "azureuser" network_interface_ids = [azurerm_network_interface.nic.id] os_disk { caching = "ReadWrite" storage_account_type = "Standard_LRS" } source_image_reference { publisher = "Canonical" offer = "UbuntuServer" sku = "18.04-LTS" version = "latest" } admin_ssh_key { username = "azureuser" public_key = [1] } }
The public_key property must contain a valid SSH public key string, typically starting with 'ssh-rsa'.
Fill both blanks to create a Network Security Group rule allowing SSH access only from a specific IP address.
resource "azurerm_network_security_rule" "ssh_restricted" { name = "SSHRestricted" priority = 1003 direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" destination_port_range = "[1]" source_address_prefix = "[2]" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name network_security_group_name = azurerm_network_security_group.nsg.name }
Port 22 is for SSH, and the source address prefix should be the specific IP address with /32 to allow only that IP.
Fill all three blanks to configure an Azure Windows VM with RDP access and a Network Security Group rule allowing RDP from any IP.
resource "azurerm_windows_virtual_machine" "winvm" { name = [1] resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location size = "Standard_B2ms" admin_username = "adminuser" admin_password = [2] network_interface_ids = [azurerm_network_interface.nic.id] os_disk { caching = "ReadWrite" storage_account_type = "Premium_LRS" } source_image_reference { publisher = "MicrosoftWindowsServer" offer = "WindowsServer" sku = "2019-Datacenter" version = "latest" } } resource "azurerm_network_security_rule" "rdp_allow" { name = "AllowRDP" priority = 1004 direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" destination_port_range = "[3]" source_address_prefix = "*" destination_address_prefix = "*" resource_group_name = azurerm_resource_group.rg.name network_security_group_name = azurerm_network_security_group.nsg.name }
The VM name should be a string like "myWindowsVM". The admin password must be a strong string. Port 3389 is used for RDP access.