-
Notifications
You must be signed in to change notification settings - Fork 182
Fix terraform error for nlb type with dualstack #662
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
Conversation
…lates to match actual resource types
Adds test coverage for NLB load balancer type to verify: - NLB without domain does not include DNS template - NLB with domain includes cf_nlb_dns template that correctly references aws_lb resources
|
the pr that introduced the dual stack feature has been reverted in #663 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for Network Load Balancer (NLB) DNS configuration by creating a new template file and updating the template generator to use it when NLB type is specified. The change separates DNS configuration for NLB resources (aws_lb) from classic ELB resources (aws_elb).
- Created
cf_nlb_dns.tftemplate that referencesaws_lbresources instead ofaws_elbresources - Updated
cf_dns.tfto remove conditional logic for dualstack, now only referencesaws_elbresources - Added NLB type to the list of supported load balancer types for LB commands
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| terraform/aws/templates/cf_nlb_dns.tf | New DNS template file for NLB that references aws_lb resources |
| terraform/aws/templates/cf_dns.tf | Simplified to remove dualstack conditionals, now only uses aws_elb resources |
| terraform/aws/template_generator_test.go | Added test coverage for NLB with and without system domain |
| terraform/aws/template_generator.go | Updated to load and use the new cf_nlb_dns template for NLB type |
| commands/aws_lbs.go | Extended LB type switch to include "nlb" alongside "cf" |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| type = "CNAME" | ||
| ttl = 300 | ||
|
|
||
| records = [one(aws_elb.iso_router_lb[*].dns_name)] |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The isolation segment DNS record references aws_elb.iso_router_lb but should reference the NLB resource instead. Based on the pattern in iso_segments.tf, this should be one(aws_lb.iso_router_nlb[*].dns_name) to match the NLB infrastructure that this template is designed for.
| records = [one(aws_elb.iso_router_lb[*].dns_name)] | |
| records = [one(aws_lb.iso_router_nlb[*].dns_name)] |
|
Please close this. I will prepare another one to ensure that the desired semantics are correct. I also want to introduce a proper CLI flag for dual stack, not just a TF variable. |
Summary
--lb-type nlbwith--dualstack=truecf_dns.tffor Classic ELBs (type "cf"),cf_nlb_dns.tffor Network LBs (type "nlb")Problem
PR #644 introduced a bug where
cf_dns.tfconditionally referencedaws_lb.*resources based onvar.dualstack, but these resources only exist whenstate.LB.Type="nlb". This caused terraform to fail with "Reference to undeclared resource" errors when users set--lb-type cf --dualstack=true.Solution
Split the DNS configuration into separate templates:
cf_dns.tf- Referencesaws_elb.*resources for type "cf"cf_nlb_dns.tf- Referencesaws_lb.*resources for type "nlb"The template generator now selects the correct DNS template based on
state.LB.Type, eliminating the conditional logic mismatch.