VpcNetworkManager keyed its VPC bindings, subnets and Docker networks
by Region and id alone, and every account's default VPC and subnets
share one id (vpc-default-<region>), so two accounts' default VPCs
shared one binding, one Docker network and one lease table: EC2
instances, Lambda functions, ECS tasks, EKS nodes and the MWAA,
CodeBuild and Batch containers of two accounts landed on the same
bridge. Ec2Service worked around the shared lease table by counting
every account's resources as holding the subnet's addresses.
- VpcNetworkManager takes the account on every call and keys bindings
and subnets by account, Region and id. A network carries the account
in its labels and, for any account but the default one, in its name;
the default account's keeps the name it always had, so its live
networks outlive the upgrade. A surviving network of another
account's VPC of the same id is a collision, as another Region's is.
- Startup reconciliation asks which accounts declare a VPC of an id in a
Region (DeclaredVpcs). A labelled network is kept while its account
declares the VPC; one an older version labelled with no account
belongs to the account declaring its VPC, the default account first,
and a non-default account's VPC keeps using that account-less network,
so its live containers stay attached across the upgrade.
- Ec2Service passes the caller's account, and the restore each stored
VPC's, subnet's and instance's own. The helpers other services call
(allocate, reserve, release, attach, detach) take the owning account
and run as it, as a caller may run outside the owner's request: a
provisioned or cross-account Lambda launch, a container removed in
the background. Lambda, ECS, EKS and VpcContainerLeases (MWAA,
CodeBuild, Batch) pass the account they already hold; Lambda's and
EKS's leases carry it to their release.
- An address is held by the caller's account's resources alone, as its
network and lease table are its own: the every-account holding check
goes, and the container lease map is keyed by account.
VpcNetworkManagerTest covers two accounts' default VPCs getting a
network each (the second's identical CIDR substituted), another
account's surviving network as a collision, a labelled network kept
only while its account declares the VPC, and an older version's
unlabelled network kept and adopted for the account declaring it. Ec2ServiceTest's cross-account
tests now pin the per-account holding. ec2.md says so.