fix: Prevent coalescelist error with database subnets and no private subnets/NAT#1296
Open
raman1236 wants to merge 1 commit into
Open
Conversation
…subnets/NAT Fixes terraform-aws-modules#944 When creating a VPC with database subnets but no private subnets and NAT disabled (enable_nat_gateway=false), Terraform fails with: 'Call to function coalescelist failed: no non-null arguments' Root cause: The database route table association tries to coalesce database and private route table IDs, but both are empty when: - create_database_subnet_route_table is false (default) - No private subnets exist Fix: Add a local.create_database_rt_association that only creates database subnet route table associations when there's actually a route table to associate with (either database or private route table). This is backward compatible - existing configurations continue to work identically since the association is only skipped when it would fail anyway.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #944
When creating a VPC with database subnets but no private subnets and NAT disabled (
enable_nat_gateway=false), Terraform fails with:Reproduction Config (from issue)
Root Cause
The
aws_route_table_association.databaseresource tries to coalesce database and private route table IDs:Both are empty when:
create_database_subnet_route_tableis false (default)private_subnets = [])Solution
Add a new local
create_database_rt_associationthat only creates database subnet route table associations when there's actually a route table to associate with (either a database or private route table).Backward Compatibility
This is fully backward compatible - existing configurations continue to work identically since the association is only skipped when it would fail anyway (no route tables exist to associate with).
Testing
create_database_subnet_route_table=true: Works (uses database route table)