Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"Error in function call" when using neither private subnets nor NAT #944

Open
Milestone
@cm-dk

Description

Description

TF errors out when trying to create a VPC with database subnets but no private subnets and no NAT gateways:
Call to function "coalescelist" failed: no non-null arguments.

It seems that the aws_route_table.private isn't created in this case (per count condition), but it is apparently meant to be referenced in aws_route_table_association.database.

  • ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [Required]: 5.0.0

  • Terraform version: 1.4.6

  • Provider version(s): 5.0.1

Reproduction Code [Required]

module "vpc" {
 source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v5.0.0"
 name = "foo"
 cidr = "10.0.0.0/16"
 azs = ["eu-central-1a", "eu-central-1b"]
 enable_dns_hostnames = true
 enable_dns_support = true
 enable_nat_gateway = false
 enable_ipv6 = false
 public_subnets = [ "10.0.0.0/24", "10.0.1.0/24" ]
 database_subnets = [ "10.0.10.0/24", "10.0.11.0/24" ]
 #private_subnets = [ "10.0.20.0/24", "10.0.21.0/24" ]
}

Expected behavior

No error.

Actual behavior

Error in function call (see below).

Terminal Output Screenshot(s)

│ Error: Error in function call
│ 
│ on .terraform/modules/vpc/main.tf line 410, in resource "aws_route_table_association" "database":
│ 410: coalescelist(aws_route_table.database[*].id, aws_route_table.private[*].id),
│ ├────────────────
│ │ while calling coalescelist(vals...)
│ │ aws_route_table.database is empty tuple
│ │ aws_route_table.private is empty tuple
│ 
│ Call to function "coalescelist" failed: no non-null arguments.

Additional context

This configuration worked fine with old version v3.2.0.

When patching the module's main.tf like this ...

 # There are as many routing tables as the number of NAT gateways
 resource "aws_route_table" "private" {
- count = local.create_private_subnets && local.max_subnet_length > 0 ? local.nat_gateway_count : 0
+ count = local.create_private_subnets || local.max_subnet_length > 0 ? local.nat_gateway_count : 0

... it works correctly. I would submit a PR, but I don't understand the logic / intention well enough to be certain that this is a proper fix for all valid configuration options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /