Adding Support for updating Availability Zones #141
Merged
+194
−36
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.
This pull request refactors the Terraform configuration to use
for_each
instead ofcount
for resources that are created per availability zone. This change improves resource management by making it easier to add or remove availability zones without destroying existing resources. Outputs are also updated to use explicit mapping by availability zone, and a new integration test is added to verify that adding an availability zone does not destroy existing resources.Resource management improvements:
public_subnets.tf
,private_subnets.tf
, andnat.tf
to usefor_each
withtoset(var.availability_zones)
instead ofcount
, ensuring stable resource addressing and preventing unnecessary resource destruction when availability zones are changed. [1] [2] [3]each.value
(the AZ name) for clearer resource identification and mapping. [1] [2] [3]Output consistency:
outputs.tf
to explicitly map resource IDs and CIDR blocks by availability zone, ensuring outputs remain stable and predictable when AZs are added or removed.Testing and validation:
spec/integration/availability_zone_addition_spec.rb
that verifies adding an availability zone results only in new resources being created, with no destruction of existing subnets, NAT gateways, or EIPs.