V
V
Vadim2019-04-26 21:29:04
Amazon Web Services
Vadim, 2019-04-26 21:29:04

Why does Terraform require either nat instance id or instance id or internet gateway id?

Good time of the day!
Question about aws and Terraform. When I create a private subnet, I try to add a default route to it for the entire VPC, like this:
from
main.tf file
resource "aws_subnet" "Private_Subnet3" {
vpc_id = "${aws_vpc.Main_VPC.id}"
cidr_block = "${ var.private_subnet3_cidr}"
availability_zone = "${var.Availability_Zone_B}"
tags {
Name = "Private Subnet 3"
}
}
resource "aws_route_table" "private-rt" {
vpc_id = "${aws_vpc.Main_VPC.id}"
route {
cidr_block = "${var.Main_VPC.cidr_block}"
}
tags {
Name = "
resource "aws_route_table_association" "private-rt" {
subnet_id = "${aws_subnet.Private_Subnet3.id}"
route_table_id = "${aws_route_table.private-rt.id}"
}
I get a runtime error where it says nat instance id or instance id must be defined
.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2019-04-26
@inoise

I'm not good at terraforming and you didn't provide information about resources - vpc, subnet, rt .... But I have a wild suspicion that you either have a subnet not in a vpc, or in general everything is in different regions or something else with a location . Nat / ig are needed when you need to bring traffic out of the vpc and back

E
Eugene, 2019-04-27
@yellowmew

Vadim
https://www.terraform.io/docs/providers/aws/r/rout...
Please note that the route block has two arguments, and you have one. In general, you need to not only specify which CIDR to route, but also what to route it through

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question