0
0
AWScloud~10 mins

Public vs private subnets in AWS - Interactive Practice

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

Complete the code to create a public subnet with automatic public IP assignment.

AWS
resource "aws_subnet" "public" {
  vpc_id            = aws_vpc.main.id
  cidr_block        = "10.0.1.0/24"
  map_public_ip_on_launch = [1]
  availability_zone = "us-east-1a"
}
Drag options to blanks, or click blank then click option'
Atrue
B"true"
Cnull
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string "true" instead of boolean true
Setting map_public_ip_on_launch to false for a public subnet
2fill in blank
medium

Complete the code to create a route in the public subnet's route table that directs internet traffic to the internet gateway.

AWS
resource "aws_route" "public_internet_access" {
  route_table_id         = aws_route_table.public.id
  destination_cidr_block = "0.0.0.0/0"
  [1]              = aws_internet_gateway.main.id
}
Drag options to blanks, or click blank then click option'
Anat_gateway_id
Binternet_gateway_id
Cgateway_id
Degress_gateway_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using nat_gateway_id instead of gateway_id for internet gateway
Using incorrect attribute names like internet_gateway_id
3fill in blank
hard

Fix the error in the private subnet route table to route internet traffic through the NAT gateway.

AWS
resource "aws_route" "private_nat_gateway" {
  route_table_id         = aws_route_table.private.id
  destination_cidr_block = "0.0.0.0/0"
  [1]              = aws_nat_gateway.main.id
}
Drag options to blanks, or click blank then click option'
Agateway_id
Bnat_gateway_id
Cinternet_gateway_id
Degress_gateway_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using gateway_id instead of nat_gateway_id for NAT gateway route
Confusing internet gateway with NAT gateway
4fill in blank
hard

Fill both blanks to create a private subnet without automatic public IP assignment and associate it with the private route table.

AWS
resource "aws_subnet" "private" {
  vpc_id                  = aws_vpc.main.id
  cidr_block              = "10.0.2.0/24"
  map_public_ip_on_launch = [1]
  availability_zone       = "us-east-1b"
}

resource "aws_route_table_association" "private_assoc" {
  subnet_id      = aws_subnet.private.id
  route_table_id = [2]
}
Drag options to blanks, or click blank then click option'
Afalse
Btrue
Caws_route_table.private.id
Daws_route_table.public.id
Attempts:
3 left
💡 Hint
Common Mistakes
Setting map_public_ip_on_launch to true for private subnet
Associating private subnet with public route table
5fill in blank
hard

Fill all three blanks to define a NAT gateway in a public subnet with an Elastic IP and associate it with the private route table.

AWS
resource "aws_eip" "nat_eip" {
  vpc = true
}

resource "aws_nat_gateway" "main" {
  allocation_id = aws_eip.nat_eip.id
  subnet_id     = [1]
}

resource "aws_route" "private_nat_route" {
  route_table_id         = [2]
  destination_cidr_block = "0.0.0.0/0"
  [3]              = aws_nat_gateway.main.id
}
Drag options to blanks, or click blank then click option'
Aaws_subnet.public.id
Baws_route_table.private.id
Cnat_gateway_id
Daws_subnet.private.id
Attempts:
3 left
💡 Hint
Common Mistakes
Placing NAT gateway in private subnet
Using public route table for private subnet route
Using gateway_id instead of nat_gateway_id for NAT gateway route