Complete the code to create a route table in AWS using Terraform.
resource "aws_route_table" "example" { vpc_id = [1] }
The vpc_id must reference the VPC's ID to associate the route table with the correct VPC.
Complete the code to add a route to the route table that directs all traffic to the internet gateway.
resource "aws_route" "internet_access" { route_table_id = aws_route_table.example.id destination_cidr_block = [1] gateway_id = aws_internet_gateway.main.id }
The destination 0.0.0.0/0 means all IPv4 traffic, which is routed to the internet gateway for internet access.
Fix the error in the route association code by completing the blank.
resource "aws_route_table_association" "example_assoc" { subnet_id = [1] route_table_id = aws_route_table.example.id }
The subnet_id must reference the subnet to associate it with the route table, not the route table or VPC IDs.
Fill both blanks to create a route that sends traffic to a NAT gateway for private subnet internet access.
resource "aws_route" "private_nat" { route_table_id = aws_route_table.private.id destination_cidr_block = [1] [2] = aws_nat_gateway.main.id }
gateway_id instead of nat_gateway_idThe destination CIDR 0.0.0.0/0 routes all traffic, and the nat_gateway_id attribute directs traffic to the NAT gateway.
Fill all three blanks to define a route table with a route and associate it with a subnet.
resource "aws_route_table" "example" { vpc_id = [1] } resource "aws_route" "example_route" { route_table_id = aws_route_table.example.id destination_cidr_block = [2] gateway_id = aws_internet_gateway.main.id } resource "aws_route_table_association" "example_assoc" { subnet_id = [3] route_table_id = aws_route_table.example.id }
The route table must be linked to the VPC ID, the route directs all traffic 0.0.0.0/0 to the internet gateway, and the association links the route table to the public subnet.