-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix(nat): Ensure NAT gateways are created in correct availability zone (#1257) #1258
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
base: master
Are you sure you want to change the base?
Conversation
|
@antonbabenko — all checks passed and requirements met. Please review when you get a chance. 🙏 |
|
@antonbabenko — all checks passed and requirements met. Please review when you get a chance |
|
@antonbabenko — All checks are passed with required changes, Please reeview it once you get some time. |
|
@antonbabenko — all checks passed and requirements met. Please review when you get a chance |
1 similar comment
|
@antonbabenko — all checks passed and requirements met. Please review when you get a chance |
|
@antonbabenko — Please respond |
|
@antonbabenko, Im waiting for a response on this |
✳️ Pull Request — Fix NAT Gateway AZ Mapping Logic (#1257)
📝 Description
This PR fixes and improves the subnet-to-AZ mapping logic in the VPC module, ensuring that NAT gateways are consistently mapped to their respective Availability Zones (AZs).
The update also improves behavior when the number of subnets differs from the number of AZs and updates example configurations accordingly.
🎯 Motivation and Context
Previously, subnet indexing caused misalignment between public/private subnets and NAT gateways when subnet counts did not match AZ counts.
This resulted in uneven NAT gateway distribution or mismatched subnet routing.
This PR ensures:
Consistent NAT gateway allocation per AZ
Flexible handling when the number of subnets > or < number of AZs
Accurate example coverage for both 2-AZ and 3-AZ configurations
✅ Fixes: #1257
⚙️ Breaking Changes
No breaking changes.
Existing configurations using standard subnet-to-AZ ratios remain fully compatible.
Only internal subnet indexing logic is refined to ensure correctness and consistency.
🧪 How Has This Been Tested?
Updated and validated
examples/completeto demonstrate proper behaviorTested with multiple configurations:
AZ = #Subnets → NAT gateways align correctly
2 AZs → validated subnet indexing logic
#Subnets > AZs → confirmed correct subnet distribution
Executed
pre-commit run -asuccessfully✅
terraform fmt,terraform_docs,tflint, andvalidatepassed✅ Wrapper modules generated successfully (
wrappers/)Verified
terraform planoutput across all scenarios📎 Test evidence and screenshots attached:
Test_Results.docx🧩 Files Updated
variables.tf— refined subnet/AZ indexing logicwrappers/main.tf— regenerated wrappersexamples/complete/main.tf— validated multi-AZ behaviorREADME.md— updated automatically byterraform_docs✅ Summary of Validation
🙌 Notes for Maintainers
The PR follows contributing guidelines
Semantic commit:
fix(vpc): correct NAT gateway AZ mapping logic (#1257)No manual changelog update required (maintainers handle this at merge)
📸 Test Artifacts
Attached:
Test_Results.docx— includes screenshots, plan outputs, and hook validation logs.