mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
* fix(ec2): resolve a NAT gateway's network interface and mark its Elastic IP associated CreateNatGateway gave each gateway address a networkInterfaceId of "eni-" + randomHex(17), but nothing else knew about that interface: DescribeNetworkInterfaces had no NAT arm, so the id DescribeNatGateways publishes (aws_nat_gateway.network_interface_id) answered InvalidNetworkInterfaceID.NotFound. The Elastic IP the gateway took was also never marked associated, so DescribeAddresses showed a held allocation as free. The interface id is now derived from the gateway id, as endpoint ENIs are, and DescribeNetworkInterfaces reports one requester-managed nat_gateway interface per gateway address, built from the stored address so the two reads cannot disagree. CreateNatGateway records the association, interface and private address on the allocation (no instanceId), and DeleteNatGateway clears them if the association is still the gateway's. * fix(ec2): refuse a NAT gateway on an occupied Elastic IP, keep its association, scope its ENI lookup to the account CreateNatGateway rejects an allocation already held by an instance or another gateway (Resource.AlreadyAssociated) under the lock that writes the association. DisassociateAddress rejects an association owned by a NAT gateway. The NAT arm of DescribeNetworkInterfaces reads gateways and subnets for the account asked about. * fix(ec2): lock NAT gateway EIP release, treat a legacy gateway's EIP as held DeleteNatGateway releases the Elastic IP under the lock CreateNatGateway takes. CreateNatGateway also refuses an allocation any live gateway references, covering gateways persisted before Address records were marked. The CloudFormation networking test gives the replacement NAT gateway a new EIP: replacement creates before it deletes, and AWS's CreateNatGateway refuses an EIP still associated elsewhere. * fix(ec2): AssociateAddress refuses a NAT gateway's Elastic IP; legacy gateways hold theirs AssociateAddress checks for a gateway holding the allocation and writes under the allocation lock CreateNatGateway and DeleteNatGateway take, so an instance cannot take over an address the gateway still claims. The gateway scan behind that check, and CreateNatGateway's, now includes unmigrated pre-account-isolation gateway records for the default account, never another account's. * fix(ec2): scope NAT gateway ownership checks to the caller's records callerNatGateways scanned every account's gateways before filtering. Read the caller's own records, plus unprefixed legacy records only for the default account. * fix(ec2): create a NAT gateway failed on an Elastic IP already in use CreateNatGateway with an allocation another gateway or an instance holds no longer answers 400. As the NatGateway shape documents, the gateway is created in state failed with FailureCode Resource.AlreadyAssociated and FailureMessage "Elastic IP address <alloc> is already associated". It gets no interface, claims nothing, and does not count as a holder. AWS::EC2::NatGateway fails the resource and deletes the failed gateway. ReleaseAddress on an allocation a NAT gateway holds, legacy gateways included, answers InvalidIPAddress.InUse. DisassociateAddress and ReleaseAddress run under privateIpAllocationLock. The NAT interface lookup reads legacy unprefixed gateways and subnets for the default account. It also loads the interface's tags, and DeleteNatGateway deletes them. endpointEniId and natEniId become one helper, eniIdFromSeed. * test(cloudformation): say why the replacement template keeps NatEip The replacement template keeps NatEip for two reasons. On AWS a gateway given an Elastic IP the displaced gateway still holds is created failed. And Floci update cleanup deletes removed resources before the old copies of replaced ones, so dropping the EIP while replacing its gateway would try to release it while it is still held. * fix(ec2): a failed NAT gateway does not pin its subnet or VPC #5503 made DeleteSubnet and DeleteVpc refuse while a NAT gateway that is not deleted sits in the subnet. A failed gateway was never created and holds no interface, so it no longer counts, matching the Elastic IP holder check.