Files
floci/docs/services
Allen Sanborn 3d455d02ad fix(route53resolver): set endpoint HostVPCId from its subnets and allocate IPs from subnet CIDR (#6886)
* fix(route53resolver): set endpoint HostVPCId from its subnets and allocate IPs from subnet CIDR

HostVPCId was derived from the endpoint id, naming a VPC that does not exist.
An IpAddress given only a SubnetId had no Ip. Resolve the subnets through EC2,
use their VPC, and allocate a free address (skipping the first four and last
of the CIDR) when Ip is omitted. Subnets EC2 does not know are still accepted.

* fix(route53resolver): follow-ups for endpoint subnet resolution

Take HostVPCId from the first subnet in request order, reuse Cidr4 for
address math, import instead of fully qualifying names, document the
unknown-subnet fallback and allocation limits, and cover replay, delete
and mixed explicit/allocated addresses.

* fix(route53resolver): allocate endpoint IPs per subnet and reject an exhausted subnet

Addresses were tracked account-wide, so two VPCs with the same subnet CIDR
skipped each other's addresses. Track them per subnet instead.

When a subnet had no free address, allocateIps stored null and the endpoint
still came back OPERATIONAL. Allocate before writing the endpoint and throw
InvalidRequestException so nothing is stored.

* fix(route53resolver): back each endpoint address with an EC2 network interface

Replaces the endpoint's own address allocator with EC2's, as AWS does
("Resolver creates a network interface for each subnet and IP address") and
as ECS already does for awsvpc tasks. Each address in a subnet EC2 knows
becomes one interface created with ec2Service.createNetworkInterface, with
the request's Ip (or one EC2 picks) and the endpoint's security groups, then
held with holdNetworkInterfaceForService. Instances, other interfaces and
other endpoints can no longer get the same address, and EC2 refuses an
explicit Ip already in use, which CreateResolverEndpoint raises as
InvalidRequestException (the model lists it and names no closer error; a
full subnet maps the same way, other EC2 refusals to
InvalidParameterException). A refusal deletes the interfaces already made.

DeleteResolverEndpoint releases and deletes the endpoint's interfaces.
ListResolverEndpointIpAddresses reports each interface's address, reading
the record once, and a JSON null Ip no longer hides it. Subnets EC2 does not
know are still accepted without an interface, and records written before
this change list and delete as before. HostVPCId still comes from the
subnets.

* fix(route53resolver): close two interface-leak windows in endpoint create and delete

DeleteResolverEndpoint was not synchronized while CreateResolverEndpoint
was. Create stores the endpoint before its record, so a delete between the
two found no interfaces to delete and the create then stored the record,
leaving an orphan record and the endpoint's interfaces behind. Delete now
takes the same lock.

The create rollback caught only AwsException, so any other failure from EC2
partway through left the interfaces already made. It now rolls back on any
RuntimeException and rethrows it; EC2 refusals are still translated.

* fix(route53resolver): create an endpoint's explicit addresses before its automatic ones

Interfaces were created in the stored (sorted) order of the address list.
An explicit IPv4 Ip happens to sort before an entry that leaves the address
to EC2, but nothing guaranteed it, and an automatic entry created first could
take the address a later entry asks for, failing the create with
InvalidRequestException though both fit. Interfaces with an explicit Ip are
now created first; the stored list keeps the request order.

* fix(route53resolver): log an endpoint interface cleanup failure instead of dropping it

The cleanup that deletes an endpoint's interfaces swallowed every EC2
error. Only an interface that is already gone is expected and stays silent;
any other failure is now logged as a warning, and the remaining interfaces
are still deleted.

* test(route53resolver): wait on the racing delete with ThreadStates and use Ec2Requests for EC2 calls

* test(route53resolver): assert the racing delete finished and route EC2 calls through one Ec2Requests helper
2026-10-30 14:55:39 -04:00
..
2026-08-21 00:09:04 -04:00