Files
floci/src
Allen Sanborn 4eae79d546 fix(ec2): canonicalize VPC and subnet CIDR blocks on create (#5214)
* fix(ec2): canonicalize VPC and subnet CIDR blocks on create

AWS stores the IPv4 CidrBlock of CreateVpc and CreateSubnet in canonical
form ("100.68.0.18/18" becomes "100.68.0.0/18"); Floci stored it
verbatim. Canonicalize once at the top of createVpc and createSubnet so
the stored block, the VPC CIDR association, the subnet conflict check and
the network declaration all use the canonical value. A null subnet CIDR
(IPv6-only subnet) stays null.

The CloudFormation VPC and subnet provisioners compare the template's
CidrBlock against the stored one to decide reuse on update; compare in
canonical form so an unchanged template with host bits set is not
replaced on every update.

* fix(cloudformation): compare saved VPC and subnet CIDRs canonically on update

VPCs and subnets persisted before CIDR canonicalization can still hold host
bits (10.0.1.9/24). Canonicalizing only the template side made an unchanged
range look changed after upgrade: the subnet path called createSubnet and hit
InvalidSubnet.Conflict, the VPC path created a replacement. Canonicalize both
sides of the reuse comparison.

* docs(ec2): generalize canonicalizeIpv4Cidr to its VPC and subnet callers

The helper now canonicalizes CreateVpc and CreateSubnet CIDRs as well as
route destinations, but its Javadoc and parameter name still described
DestinationCidrBlock only. Rename the parameter to ipv4CidrBlock, cover all
three callers in the Javadoc, and drop its em-dashes. No behavior change.

* refactor(cidr): add CidrCanonicalizer.sameBlock for the provisioner comparisons

The subnet and VPC reuse checks each canonicalized both sides inline. Move
that comparison into one helper next to canonicalize, with the same
fallback to the raw string for an unparseable side and the same null
handling. No behavior change.
2026-10-07 14:09:24 -04:00
..