You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running the code solution in branch 04_01, terraform returns errors:
Error: Error in function call
on .terraform/modules/blog_vpc/main.tf line 1087, in resource "aws_route" "private_nat_gateway":
route_table_id = element(aws_route_table.private[*].id, count.index)
while calling element(list, index)
aws_route_table.private is empty tuple
count.index is [NB: terraform returns 3 errors, all with the same trace except here, where count.index ranges between 0 and 2.]
Call to function "element" failed: cannot use element function with an empty list.
The text was updated successfully, but these errors were encountered:
The code in the video has the following for the VPC module : enable_nat_gateway = true. To understand the error you need to understand why we would want a NAT gateway.
NAT gateways are used when you want EC2 instances in a private subnet to be able to connect to the internet for things like Linux package updates, but you do not want devices outside the private subnet to be able to connect to the instances (like with ssh). The NAT gateway is on a public subnet in your VPC, and an entry for the IP of that NAT gateway is added to the route table of the private subnet.
The Problem :: The configuration in the video asks for a NAT gateway, but there aren't any private subnets with a route table to update with the IP of that NAT gateway. The error is saying that you have an empty list of private subnets. Put another way, the configuration is incomplete.
You can fix the error by removing the enable_nat_gateway = true setting.
When running the code solution in branch 04_01, terraform returns errors:
The text was updated successfully, but these errors were encountered: