Files
floci/src/main/java/io/github
Allen Sanborn c32f8b5a24 fix(ec2): place a subnet in the zone its request names, not always az1 (#2890)
* fix(ec2): place a subnet in the zone its request names, not always az1

CreateSubnet never read AvailabilityZoneId, and hardcoded every new subnet's
zone id to the region's first zone. Two consequences, and the second bites even
a caller that never mentions a zone id: a subnet asked for us-east-1-az2 came
back in us-east-1-az1, and a subnet placed correctly by zone *name* still
reported az1, contradicting its own availabilityZone.

Anything that selects subnets by zone id therefore saw one zone -- Terraform's
aws_subnet.availability_zone_id, and any client that pairs subnets against the
DescribeAvailabilityZones list it just read.

AvailabilityZoneId is now honoured, and the zone id is derived from the zone
rather than fixed. The derivation is the mapping DescribeAvailabilityZones and
the seeded default subnets were already using independently; all three now come
through one helper, so a subnet's zone id agrees with the zone list by
construction instead of by coincidence.

A zone and a zone id that disagree are refused with InvalidParameterCombination
rather than silently resolved to one of them -- Terraform's aws_subnet forbids
setting both, so a request carrying both contradictory values is a bug in the
caller, not something to guess at. A malformed zone id is refused too.

* fix(ec2): refuse a zone id this region does not publish

The first version resolved any well-formed zone id, so us-east-1-az4 created a
subnet in a zone DescribeAvailabilityZones does not list. That is the same
inconsistency the hardcoded az1 produced, only quieter: a client pairing subnets
against the published zone inventory still cannot resolve the subnet's zone.

The three modelled zones are now one constant that DescribeAvailabilityZones,
the seeded default subnets and this validation all read, so they cannot drift,
and the error names the range rather than only rejecting.

Also logs the tolerated NumberFormatException instead of swallowing it, and
drops this branch's em-dashes, both per AGENTS.md.
2026-09-01 12:13:34 -04:00
..