Skip to content

fix(terraform): guard NAT gateway outputs against disabled NAT#41

Merged
basebandit merged 3 commits into
chore/refactor-with-enhancementsfrom
copilot/sub-pr-37-yet-again
Feb 9, 2026
Merged

fix(terraform): guard NAT gateway outputs against disabled NAT#41
basebandit merged 3 commits into
chore/refactor-with-enhancementsfrom
copilot/sub-pr-37-yet-again

Conversation

Copilot AI commented Feb 9, 2026

Copy link
Copy Markdown

Terraform outputs for NAT gateway IDs and IPs were directly indexing arrays without checking if NAT gateways were enabled, causing plan failures when enable_nat_gateway=false.

Changes

  • Wrapped nat_public_ips[0] and natgw_ids[0] with try() to return null when NAT is disabled
  • Updated output descriptions to document null fallback behavior
# Before
output "nat_gateway_id" {
  value = module.vpc.natgw_ids[0]  # Errors if list is empty
}

# After  
output "nat_gateway_id" {
  value       = try(module.vpc.natgw_ids[0], null)
  description = "ID of the NAT Gateway (null if NAT gateway is disabled)"
}

Addresses feedback in #37 (comment)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…disabled

Co-authored-by: basebandit <8973567+basebandit@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback from review on refactor fix(terraform): guard NAT gateway outputs against disabled NAT Feb 9, 2026
Copilot AI requested a review from basebandit February 9, 2026 05:46
@basebandit basebandit marked this pull request as ready for review February 9, 2026 07:21
@basebandit basebandit merged commit 3c16fb4 into chore/refactor-with-enhancements Feb 9, 2026
@basebandit basebandit deleted the copilot/sub-pr-37-yet-again branch February 9, 2026 07:21
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

Successfully merging this pull request may close these issues.

2 participants