0
0
Azurecloud~10 mins

Subnets within a VNet in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a virtual network with an address space.

Azure
resource "azurerm_virtual_network" "example" {
  name                = "example-vnet"
  location            = "eastus"
  resource_group_name = "example-resources"
  address_space       = ["[1]"]
}
Drag options to blanks, or click blank then click option'
A172.16.0.0/12
B192.168.1.0/24
C10.0.0.0/16
D255.255.255.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a subnet mask like '255.255.255.0' instead of CIDR notation.
Using a public IP range instead of a private IP range.
2fill in blank
medium

Complete the code to define a subnet within the virtual network.

Azure
resource "azurerm_subnet" "example_subnet" {
  name                 = "example-subnet"
  resource_group_name  = "example-resources"
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["[1]"]
}
Drag options to blanks, or click blank then click option'
A10.0.0.0/16
B10.0.1.0/24
C192.168.1.0/24
D172.16.0.0/12
Attempts:
3 left
💡 Hint
Common Mistakes
Using an address prefix outside the VNet's address space.
Using the same prefix as the VNet address space.
3fill in blank
hard

Fix the error in the subnet address prefix to be valid within the VNet.

Azure
resource "azurerm_subnet" "wrong_subnet" {
  name                 = "wrong-subnet"
  resource_group_name  = "example-resources"
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["[1]"]
}
Drag options to blanks, or click blank then click option'
A10.0.2.0/24
B10.0.0.0/16
C10.1.0.0/24
D192.168.1.0/24
Attempts:
3 left
💡 Hint
Common Mistakes
Using a subnet prefix that overlaps the entire VNet.
Using an address prefix outside the VNet range.
4fill in blank
hard

Fill both blanks to define a subnet with network security group association.

Azure
resource "azurerm_subnet" "secure_subnet" {
  name                 = "secure-subnet"
  resource_group_name  = "example-resources"
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["[1]"]
  network_security_group_id = azurerm_network_security_group.example.[2]
}
Drag options to blanks, or click blank then click option'
A10.0.3.0/24
Bid
Cname
Dlocation
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' or 'location' instead of 'id' for NSG association.
Using an invalid subnet prefix outside the VNet.
5fill in blank
hard

Fill all three blanks to define a virtual network with two subnets.

Azure
resource "azurerm_virtual_network" "multi_subnet_vnet" {
  name                = "multi-subnet-vnet"
  location            = "eastus"
  resource_group_name = "example-resources"
  address_space       = ["[1]"]
}

resource "azurerm_subnet" "subnet1" {
  name                 = "subnet1"
  resource_group_name  = "example-resources"
  virtual_network_name = azurerm_virtual_network.multi_subnet_vnet.name
  address_prefixes     = ["[2]"]
}

resource "azurerm_subnet" "subnet2" {
  name                 = "subnet2"
  resource_group_name  = "example-resources"
  virtual_network_name = azurerm_virtual_network.multi_subnet_vnet.name
  address_prefixes     = ["[3]"]
}
Drag options to blanks, or click blank then click option'
A10.1.0.0/16
B10.1.1.0/24
C10.1.2.0/24
D10.2.0.0/24
Attempts:
3 left
💡 Hint
Common Mistakes
Using subnet prefixes outside the VNet address space.
Using overlapping subnet prefixes.