Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code 04_01 error in function call: aws_route_table.private is empty tuple #80

Open
atticus-trellix opened this issue May 23, 2023 · 1 comment

Comments

@atticus-trellix
Copy link

atticus-trellix commented May 23, 2023

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.

@patrickodacre
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants