mirror of
https://github.com/floci-io/floci.git
synced 2026-11-28 16:11:48 -05:00
c149ef7166aaa82fda09b42c96ff87828eb8cb7f
144
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ecd1138d86 |
feat(ec2): support GetConsoleOutput with the guest's SSH host keys (#7385)
Returns a console log carrying the instance's SSH host public keys between the markers cloud-init prints, read from the running instance container, so clients can verify the host before connecting. An instance without a running container has an empty log. Look the instance up in the request's region, read host keys only from a running container and treat a failed read as an empty log, build the response with XmlBuilder, and cover the SDK reading of the response. AWS returns DryRunOperation for DryRun=true even for an empty or malformed instance id, so check the dry run first. The key files are the guest's to write, so capture at most 16 KiB of stdout (and 1 KiB of stderr) through bounded streams, and answer an empty log, with a warning, when the output is larger than host keys can be. |
||
|
|
3b8c524df0 |
fix(ec2): include processor manufacturer metadata (#7517)
Populate existing instance types with AWS-verified manufacturer values and expose them through DescribeInstanceTypes. Add SDK regression coverage for all 84 catalog entries. Closes floci-io/floci#7516 |
||
|
|
ee78a41f16 |
fix(ec2): honor network interface selectors in AssociateAddress (#7506)
* fix(ec2): associate elastic addresses with primary and detached interfaces Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> (cherry picked from commit 28c17835d6e7dc480f5f5716e206fbbe5b81bee0) Signed-off-by: Jackson Price <jxnprice@amazon.com> * test(ec2): clean up partial address-association fixtures Signed-off-by: Jackson Price <jxnprice@amazon.com> * fix(ec2): serialize interface deletion and resolve managed interfaces Signed-off-by: Jackson Price <jxnprice@amazon.com> --------- Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> Signed-off-by: Jackson Price <jxnprice@amazon.com> Co-authored-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
71e8725a45 |
fix(ec2): expand Graviton instance type metadata (#7501)
Add the missing virtual sizes in C6g, C6gn, C7g, C8g, M6g, M7g and M8g using captured AWS type metadata. Verify metadata and offerings through the Java SDK. Closes floci-io/floci#7500 |
||
|
|
7b4e568ce4 |
fix(ec2): validate launch template selectors and honor dry runs (#7497)
* fix(ec2): honor launch template modification dry runs Signed-off-by: Andre Kurait <akurait@amazon.com> (cherry picked from commit a76af5e62cf32eacdab4ce71dc0b5c0866de7b25) Signed-off-by: Jackson Price <jxnprice@amazon.com> * fix(ec2): reject conflicting launch template selectors Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> (cherry picked from commit 50dfad42ed80c9694e77dcb24be3825b8ed32552) Signed-off-by: Jackson Price <jxnprice@amazon.com> Co-authored-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
efe6cbc78a |
feat(ec2): report the service-network address as public IP when Floci runs in a container (#7384)
* feat(ec2): report the service-network address as public IP when Floci runs in a container Adds FLOCI_SERVICES_EC2_PUBLIC_IP_FROM_SERVICE_NETWORK (default false). When Floci itself runs as a container and the option is on, an instance's public IP is its address on Floci's own Docker network, so clients on that network reach the guest's real ports, port 22 included. * fix(ec2): record the service-network address and follow protected guests to their helper Resolve the address once at launch, start and restore instead of asking Docker on every public-address read, which DescribeAddresses does under a lock. A security-group protected guest shares its firewall helper's network namespace, so its address is the helper's. * fix(ec2): share the helper lookup and retry a failed service-network lookup Use one container: network-mode lookup for protectedNamespace and the service-network address. A lookup that fails on a Docker error is no longer recorded as the answer; the next address read retries it on the executor without waiting. * fix(ec2): run service-network lookup retries off the launch pool Retries ran on the bounded launch executor, whose blocking backpressure could leave launch workers waiting on each other. They now get their own virtual-thread executor, and a retry that cannot be scheduled is logged with the instance id. * fix(ec2): publish a service-network lookup only for the container it read A lookup records the container it starts for, asks Docker outside the instance lock, and publishes under the lock only while the instance still runs that container, so a lookup that outlives a replacement or a teardown cannot overwrite what came after it. The retry executor now comes in through the package-private constructor and is final. |
||
|
|
196b672563 |
feat(ec2): EC2 Instance Connect Endpoint control plane (#7359)
* feat(ec2): EC2 Instance Connect Endpoint control plane CreateInstanceConnectEndpoint, DescribeInstanceConnectEndpoints and DeleteInstanceConnectEndpoint answered UnknownOperation, so Terraform's aws_ec2_instance_connect_endpoint failed at create and the AWS CLI's `ec2-instance-connect ssh --connection-type eice` could not look an endpoint up. They now carry the fields, filters and errors Terraform and the CLI use. Endpoint DNS names are <id>.localhost.floci.io, which public DNS resolves to 127.0.0.1, and each endpoint takes a private address in its subnet. As on AWS, a live endpoint makes DeleteSubnet and DeleteVpc fail with DependencyViolation (a destroy ordered wrongly would otherwise pass here and fail on AWS, and the endpoint's address reservation leaked), and a replayed ClientToken returns the first endpoint instead of creating a duplicate on an SDK or Terraform retry. The tunnel the endpoint serves is a separate change. * fix(ec2): create an EC2 Instance Connect Endpoint under the subnet topology lock Two creates with one ClientToken could both miss the replay scan and make two endpoints, and a DeleteSubnet could land between the subnet check and the save, leaving an endpoint on a subnet that is gone. The create now holds the lock DeleteSubnet holds. The endpoint store is final and comes through the constructor chain like the other stores, and the service test is named Ec2InstanceConnectEndpointServiceTest. * test(ec2): name the exceptions the endpoint race test expects * fix(ec2): return a copy from instance connect endpoint reads Create, Describe and Delete handed back the stored endpoint itself, with its tags written onto it, and Delete then set delete-in-progress on that object. A caller changing a returned endpoint changed the stored one. They now return a copy carrying the current tags. * fix(ec2): scan one region's instance connect endpoints by key on describe Describe read every region's endpoints and kept those whose region field matched, while the ClientToken replay scan picks a region by store key. Describe now uses the key prefix too, so the two agree on what is in a region and describe no longer reads other regions' records. * fix(ec2): compare every creation parameter on an instance connect endpoint ClientToken replay A replayed ClientToken compared only SubnetId, so a retry with other security groups, IpAddressType, PreserveClientIp or tags returned the first endpoint as if it matched. Each is now compared after defaults are applied and a difference is IdempotentParameterMismatch, as the egress-only internet gateway create does. Tags are compared as the create request carried them, so a later CreateTags does not turn a retry into a mismatch. * test(ec2): drive instance connect endpoints over the EC2 Query wire The service test called Ec2Service directly, so nothing covered the query handler: SecurityGroupId.N and TagSpecification.N parsing, the ClientToken echo, and the Create, Describe and Delete response envelopes. The integration test creates, replays, describes and deletes an endpoint through the HTTP endpoint and reads each result back with a separate Describe. * fix(ec2): validate instance connect endpoint requests before answering DryRun CreateInstanceConnectEndpoint answered DryRunOperation before checking the subnet, IpAddressType or security groups, and Describe and Delete ignored DryRun and acted on the request. Create now validates and then answers DryRunOperation, as RunInstances and ReplaceRoute do, and Describe and Delete check the IDs and filters first, then answer DryRunOperation without deleting anything. * fix(ec2): page DescribeInstanceConnectEndpoints by MaxResults and NextToken MaxResults and NextToken were ignored and every match came back on one page. Describe now returns at most MaxResults endpoints in ID order with a nextToken for the rest, using the shared opaque-cursor pagination, and an unreadable NextToken is InvalidParameterValue as DescribeDhcpOptions answers it. MaxResults is not range-checked against the model's 1-50. * fix(ec2): range-check MaxResults on DescribeInstanceConnectEndpoints and compare replayed security groups as a set The model's InstanceConnectEndpointMaxResults allows 1 to 50, but a sent 0, negative or larger value was served. It is now InvalidMaxResults, as DescribeTags and DescribeEgressOnlyInternetGateways refuse values outside their own ranges; an omitted MaxResults still returns every match. A test now pins that a ClientToken replay naming the same security groups in another order returns the first endpoint. * docs(ec2): name instance connect endpoints among the private address holders privateIpsInUse and privateIpsHeldOnVpcNetwork count the addresses EC2 Instance Connect Endpoints hold, but their comments listed only instances, network interfaces and NAT gateways. * test(ec2): refuse a NAT gateway the private address an instance connect endpoint holds CreateNatGateway with a PrivateIpAddress an EC2 Instance Connect Endpoint holds answers InvalidIPAddress.InUse, and the address is free again once the endpoint is deleted. Nothing covered the endpoint's share of the in-use scan before. * fix(ec2): copy each creation tag of an instance connect endpoint The copy constructor copied the creationTags list but shared its Tag objects with the stored endpoint, and the create stored the request's own Tag objects. Changing a tag on a returned endpoint, or on the list passed to the create, changed the saved creation parameters, so a retry with the same ClientToken and the original tags failed with IdempotentParameterMismatch. Copy each Tag when saving and when returning a copy. * fix(ec2): reject an unknown DescribeInstanceConnectEndpoints filter before scanning An unknown filter name was rejected only while testing it against an endpoint, so with no endpoints, or when an earlier filter excluded them all, the bad name succeeded silently. Check every name up front through requireSupportedFilters, as DescribeVpcs and DescribeVpnGateways do, with the same InvalidParameterValue. * fix(ec2): resolve an instance connect endpoint's interface in DescribeNetworkInterfaces CreateInstanceConnectEndpoint published an interface ID in networkInterfaceIdSet that DescribeNetworkInterfaces answered with InvalidNetworkInterfaceID.NotFound, so a client could not read the endpoint's private address or security groups from it. Build the interface from the endpoint in the describe path, as the NAT gateway and interface VPC endpoint arms already do: a requester-managed ec2_instance_connect_endpoint interface with the endpoint's subnet, VPC, private address and security groups, present while the endpoint exists. Its address is already counted from the endpoint record, so subnet address accounting is unchanged. DeleteInstanceConnectEndpoint also drops the interface's own tags, as DeleteNatGateway does. * fix(ec2): name an instance connect endpoint interface's groups from the account it is read for The explicit-account DescribeNetworkInterfaces overload scanned the named account's endpoints but looked their security group names up under the ambient request account, so a caller in another account got the groups back without names. Read the group for the same account, as natNetworkInterfacesOf reads its subnet. * test(ec2): keep another account's instance connect endpoint interface out of DescribeNetworkInterfaces An endpoint created in one account is NotFound by NetworkInterfaceId and absent from an unfiltered list for another account, and still visible to its own. * fix(ec2): accept exactly AWS's DescribeInstanceConnectEndpoints filters The DescribeInstanceConnectEndpoints reference lists instance-connect-endpoint-id, state, subnet-id, tag:<key>, tag-key, tag-value and vpc-id. Implement tag-value (any tag's value in the filter values, as the other EC2 describe calls match it) and stop accepting availability-zone and owner-id, which the reference does not list; they are now refused as InvalidParameterValue like any unknown filter. * refactor(ec2): build NAT gateway and instance connect endpoint interfaces once natNetworkInterfacesOf and instanceConnectEndpointNetworkInterfacesOf set up the same requester-managed interface with one primary address; both now call requesterManagedInterface. Their two DescribeNetworkInterfaces arms, identical but for the interfaces they walk, become one arm over NAT interfaces then endpoint interfaces, the order the two arms ran in. No behaviour change. * test(ec2): share a mock-mode Ec2Service builder in the test fixtures Ec2ServiceFixtures.mockModeService() in the shared testing package builds the mock-mode Ec2Service over in-memory storage that Ec2InstanceConnectEndpointServiceTest built privately, and that class now uses it. The other classes with their own copy move to it separately. * docs(ec2): count the three InstanceConnectEndpoint operations in the service matrix |
||
|
|
d481f8396c |
fix(ec2): serialize VPC deletion with Docker network creation (#7470)
Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> (cherry picked from commit 7797b47de690c157d056866de6e51eaa7ae86301) Co-authored-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
a772b27583 |
feat(ec2): add Client VPN endpoints, associations, rules and routes (#7425)
* feat(ec2): add Client VPN endpoints, associations, rules and routes Store Client VPN endpoints with their target network associations, authorization rules and routes, and export the OpenVPN client configuration from the server certificate held in ACM. Fifteen EC2 Query actions; no VPN server runs. * fix(ec2): apply Client VPN describe filters and pin associated subnets Apply AWS's filters on the four Client VPN describe operations and refuse unknown ones. Report selfServicePortalUrl for an endpoint with the portal enabled. Require every requested security group to exist. Register associations as subnet and VPC dependencies, saved under the subnet reference lock. Compare rule and route CIDRs as networks. Replace the endpoint's lists instead of changing them in place, and let only a missing ACM certificate leave the export without its CA. * refactor(ec2): share the Query protocol helpers and the id hex generator Move the EC2 Query parameter and response helpers Ec2QueryHandler kept private (getList, getFiltersList, boolParam, intParam, tagSetXml, booleanResponse, xmlResponse) into Ec2QueryProtocol, which the Client VPN handler now uses too, and replace the four randomHex copies in Ec2Service, Ec2IpamService, FlowLogService and Ec2ClientVpnService with Ec2Ids.randomHex. The Client VPN test builds its requests through testing.Ec2Requests. * style(ec2): brace the loop exits in Ec2QueryProtocol |
||
|
|
fbfe9048a1 |
fix(ec2): support NAT gateway secondary addresses (#7327)
* fix(ec2): support NAT gateway secondary addresses * fix(ec2): update a NAT gateway's secondary addresses in place A CloudFormation update that changed only a NAT gateway's Secondary* properties replaced the gateway. The replacement was created while the old gateway still held its Elastic IP or fixed private address, so it came back failed with Resource.AlreadyAssociated (or InvalidIPAddress.InUse) and the update failed. The schema does not mark the secondaries create-only, so AWS changes them in place and the gateway keeps its id. Ec2Service.updateNatGatewaySecondaryAddresses sets a gateway's secondaries to the requested ones: kept ones stay, dropped Elastic IPs are handed back, new ones are checked as CreateNatGateway checks them, and every check runs before anything changes. The provisioner calls it instead of replacing, and records the prior secondaries so a rolled-back update puts them back. * fix(ec2): keep a NAT gateway's picked secondary when listed ones change The counted slots of an in-place secondary update kept the first secondary with no Elastic IP and an address the request does not list. With SecondaryPrivateIpAddresses [A] and a count of 1 changed to [B] and 1, that was the dropped listed A, while the address the subnet had picked was given up. Counted addresses always follow the listed ones, so the counted slots now keep the last such secondaries, in order. Tests cover a count changed in place (an unrelated change keeps the same addresses; 1 to 2 keeps the first; 2 to 1 keeps one of them), the picked address surviving a listed change, and secondary Elastic IPs swapped between listed addresses or moved to a new one, with DescribeAddresses showing each held at its new address. * test(ec2): pin which counted NAT gateway secondary an update keeps The counted slots keep the last unlisted secondaries, so a count lowered from 2 to 1 keeps the second address; the test now asserts that, and that raising the count from 1 to 2 adds a new address in the subnet after the kept one. The comment no longer claims counted addresses always follow the listed ones: slot position is the only record of an address's origin, and across updates a once-listed address can move behind a picked one. * fix(ec2): read a NAT gateway under the allocation lock before updating its secondaries The secondary-address update read the gateway before taking the lock that DeleteNatGateway holds. A delete finishing in between left the update holding a stale copy, which it then wrote back, re-associating the Elastic IPs the delete had released and overwriting the association of a gateway that had since taken the primary one. The gateway is now read again under the lock, and one that is gone or deleted is refused with NatGatewayNotFound. * test(cloudformation): read NAT gateway addresses through XmlParser The secondary-address tests picked addresses out of DescribeNatGateways and DescribeAddresses with a regular expression and substring checks that depended on element order. They now select the non-primary items of natGatewayAddressSet through XmlParser. * test(ec2): cover a NAT gateway stored as deleted by a racing tag write CreateTags writes a NAT gateway back under the gateway's tag lock, which DeleteNatGateway does not take. A tag write that read the gateway before a delete therefore stores the very record the delete marked deleted, so the secondary-address update's deleted-state check is reachable. The test pauses the tag write's put, deletes the gateway, lets the put finish, and asserts the update refuses the record with NatGatewayNotFound and holds no Elastic IP for it. * refactor(ec2): fill a NAT gateway's address slots in one place CreateNatGateway and the secondary-address update each walked the gateway's slots the same way: take the listed Elastic IP and address at each position, assign a free address where none is listed, build the address, and give back what was assigned if a later slot fails. Both now call fillNatGatewaySlots. Create passes its primary address as slot 0 and marks it primary afterwards; the update passes the slots its kept secondaries already fill. The order addresses are assigned in, the error codes and the release on failure are unchanged. * test(ec2): cover NAT gateway lease release and reuse the shared test helpers No test covered the lease a NAT gateway gives back when its addresses run out part way, so the shared slot-filling walk could lose its release with every test green. Two tests now run a /28 subnet out of addresses, one through CreateNatGateway and one through a secondary-address update, and verify the lease taken on the VPC network is released and that the update leaves the gateway as it was. The concurrent-delete test now builds its service with mockModeService() and waits for the blocked update with ThreadStates.awaitBlockedOrDone. * test(ec2): build the small NAT subnet with privateSubnet |
||
|
|
f22d0409ac |
fix(eks): let guest kubelet own worker node registration (#7420)
* fix(eks): let guest kubelet own worker node registration Honor an explicit image catalog capability on initial join and replay. Preserve simulated registration by default and retain join bookkeeping and listeners. Closes floci-io/floci#7419 * test(eks): clean up the kubelet registration worker independently Retain the launched instance ID and terminate it in the original account and region. Attempt worker, tracking and cluster cleanup independently and verify the worker reaches terminated state. |
||
|
|
f489a6f1f3 | feat(ec2): support AMI block public access (#7134) | ||
|
|
f77d032818 |
fix(ec2): include r5.large in the instance type catalog (#7146)
* fix(ec2): include r5.large in the instance type catalog Promote the complete retained fork #234 catalog entry and SDK regression on current main. Keep catalog metadata and offerings consistent. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> * test(ec2): use JUnit and Hamcrest for R5 catalog assertions Preserve all 18 metadata and offering assertions while following the src/test assertion conventions requested in review. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> --------- Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
d173d65eb4 |
fix(ec2): honor CopyImageTags on CopyImage (#7097)
* fix(ec2): tag an AMI with the tags RegisterImage is given RegisterImage never read TagSpecification, so an AMI registered with image tags came back from DescribeImages untagged: its tag filters matched nothing and DescribeTags listed nothing for it. A tag specification for another resource type was accepted as well, although AWS fails that request. RegisterImage now reads its image tag specifications and refuses any other resource type with InvalidParameterValue. It checks the tags as CreateTags does (no aws: prefix, the key and value lengths, at most 50 tags) before registering anything, so a refused request leaves no AMI behind. The tags are stored before the AMI is, so DescribeImages never lists it without them, and a key given twice keeps its last value, as Floci's CreateTags keeps it. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): copy an AMI's tags when CopyImage sets CopyImageTags CopyImage never read CopyImageTags, so a copy asked to carry its source's tags came out untagged, and DescribeImages could not find it by them. With CopyImageTags=true the copy now gets the caller's tags on the source, read in the source region, less the aws: system tags, which AWS does not copy either. Without it, or with false, no tags are copied, which is AWS's default. The source keeps its tags, and the copy's are stored in the destination region only. The tags are read under the source AMI's own id, so a catalog AMI's tags on that id are copied too, while tags put on one of its aliases are not. Floci keeps each account's tags apart, so another account's tags never reach the copy. CopyImage still neither checks nor applies TagSpecification, and the docs now say so. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): stub the CopyImage overload the handler calls Upstream's handler test for CopyImage tag specifications stubbed the five-argument copyImage. On this branch the handler passes CopyImageTags as well, so the stub never matched, the mock returned null and the test failed with a NullPointerException. It now stubs the six-argument call with CopyImageTags false, which is what a request without it sends. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * refactor(ec2): leave RegisterImage tag specifications to upstream's handling Upstream now reads RegisterImage's TagSpecification in the Query handler, refuses other resource types and checks the tags before the AMI is registered, so this branch's own path for the same thing is a duplicate. The seven-argument registerImage overload and the tag code in registerImageLocked are removed, and RegisterImage goes back to upstream's code. CopyImage stores the tags it copies straight after it registers the copy instead. The branch's RegisterImage tests go too: upstream's Ec2CreateTagSpecificationIntegrationTest and Ec2QueryHandlerTest cover the same behaviour. What the branch adds is CopyImageTags alone. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): pin a TagSpecification tag over a copied tag of the same key With CopyImageTags=true and an image TagSpecification on the same request, the copy carries both sets. When both name the same key, the TagSpecification value is the one the copy keeps, since the handler applies the specification after the service copies the source's tags. The docs row says so; this test holds it. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): refuse a CopyImage over the tag limit before creating the copy With CopyImageTags=true and an image TagSpecification, the copied and the specified tags were each checked against the 50-tag limit on their own. The service then created the AMI and its snapshots and stored the copied tags, and only the handler's CreateTags of the specification saw the combined set: past 50 it answered TagLimitExceeded while the copy it had just made stayed behind, so a retry under the same Name failed with InvalidAMIName.Duplicate. The handler now passes the requested image tags to the service, which checks the union of copied and requested keys before it registers anything. The upstream handler test stubs the new signature. The docs and the test of a key given both ways now say that the TagSpecification value winning is Floci's behaviour: the public CopyImage reference does not say how AWS settles that. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * refactor(ec2): keep one CopyImage service signature --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> |
||
|
|
dbb1ff6d89 |
fix(autoscaling): launch with the launch configuration's block devices (#7098)
* fix(autoscaling): launch with the launch configuration's block devices Auto Scaling groups launching from a launch configuration passed none of its block device mappings to the launch, so their instances got the AMI's devices alone. They now pass them, with the configuration's Boolean NoDevice converted to EC2's marker, and instance refresh replacements get them too. A mapping the launch refuses, such as an invalid device name, now fails the launch as a failed scaling activity. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): count volume store scans for a DescribeInstances response The test for one volume read per DescribeInstances response counted calls to instanceVolumeAttachments, so a scan moved inside that helper's instance loop still passed it. It now counts scans of the volume store for a three-instance response, which fail with three scans both before the fix and with that loop. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(autoscaling): default launch configuration volumes to delete on termination * test: share signed Query requests for launch block devices --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> |
||
|
|
e3cdb72171 | fix(ec2): set the link-local IMDS endpoint up again when an instance starts (#6873) | ||
|
|
3b4a2ec14d |
fix(ec2): propagate transit gateway attachments to the default propagation route table (#7060)
* fix(ec2): propagate transit gateway attachments to the default propagation route table * refactor(ec2): build transit gateway route table propagations in one helper The default-propagation path in storeNewAttachment and enableTransitGatewayRouteTablePropagation built the same propagation record field for field. Both now call storePropagation. * test(ec2): assert the resource id of a default-created propagation The create-site VPC id argument to the propagation helper was not checked by any test; only the resource type was. |
||
|
|
dcf8ec7430 |
fix(ec2): report NAT gateways as zonal and honor PrivateIpAddress (#7059)
* fix(ec2): report NAT gateways as zonal and honor PrivateIpAddress The Terraform AWS provider reads network_interface_id, private_ip and public_ip from a NAT gateway only when it is reported with availabilityMode zonal. Floci never sent availabilityMode, so all three stayed null. Every gateway Floci creates sits in one subnet, so the responses now say zonal. Floci has no regional NAT gateways. A regional request that named only its VPC failed on the missing subnet, and one that also named a subnet got a zonal gateway, through both CreateNatGateway and AWS::EC2::NatGateway. Both now refuse AvailabilityMode regional with UnsupportedOperation. Any other value except zonal, such as Regional, fails with InvalidParameterValue instead of creating a zonal gateway. Once Terraform reads private_ip back, the gateway has to hold the address it was asked for. private_ip forces a new gateway, and CreateNatGateway ignored PrivateIpAddress, so a config that set it would plan a replacement on every run. CreateNatGateway and AWS::EC2::NatGateway now give the gateway's interface the requested address, checked by the same rules as RunInstances: inside the subnet, not reserved and not in use. A changed PrivateIpAddress replaces the CloudFormation resource, as it is createOnly. A gateway has its primary address only, so SecondaryAllocationIds, SecondaryPrivateIpAddresses and SecondaryPrivateIpAddressCount are refused with UnsupportedOperation instead of being dropped. AWS::EC2::NatGateway also sets EniId, the gateway's primary interface, which Fn::GetAtt resolved to the literal "Nat.EniId" although the gateway has had a real interface since #5622. Closes #6767 * fix(ec2): take no VPC network lease for a NAT gateway's requested address DeleteNatGateway never returns a lease, so the one CreateNatGateway took for its PrivateIpAddress kept the address from automatic allocation after the gateway was gone. Check that the address is free the way CreateNetworkInterface does, without the lease; automatic allocation already steps around addresses a stored NAT gateway holds. Ec2NatGatewayAddressIntegrationTest now sends its requests through the shared Ec2Requests.ec2 instead of its own copy. |
||
|
|
ddae4fdbe9 |
fix(ec2): remove a VPC's network after a restart too (#6874)
* fix(ec2): remove a VPC's network after a restart too deleteVpcNetwork removed a VPC's Docker network only when this process had materialised it (vpc.created), which happens when an instance in the VPC starts. After a restart, a VPC that kept its network from the previous run but had no instance started since was deleted without its network: the bridge outlived the VPC and held its CIDR, so the next VPC declaring that CIDR collided with it. Reproduced by: run an instance in a VPC, restart with persisted state, terminate it, delete the VPC, create one with the same CIDR. Startup reconciliation already lists this deployment's VPC networks and keeps those whose VPC is still declared; it now remembers them, and deleting such a VPC removes its network. The listing runs whether or not reconcile-on-startup is on (only reaping orphans is behind that flag), so the fix does not depend on it. Upstream #5869 already detaches Floci before removal; this keeps that path. * fix(ec2): remove a restored VPC's network by the name it has Startup reconciliation remembered only which VPCs kept a network from a previous run, and deleting such a VPC then removed the name this version computes, floci-aws-vpc-.... A network created before the floci-aws- prefix is named floci-vpc-...; removing the computed name found nothing, the NotFound was ignored, and the old bridge kept holding the CIDR. Reconciliation now records each surviving network's own name and the deletion removes that one, along with the computed one if this run materialised it. * test(ec2): cover deleting a VPC this run materialised after a restart A VPC an instance started in after the restart has both the network this run created and the one its predecessor left. Deleting it removes both when the predecessor's carries a legacy name, and removes one network once when this run reused the predecessor's. * fix(ec2): remember every surviving network of a VPC after a restart Startup reconciliation kept one network name per VPC, so when both the legacy-named and the current-named bridge survived, deleting the VPC before this run materialised it left one behind with its CIDR reserved. |
||
|
|
8dbcf6bf17 |
fix(ec2): read RunInstances security groups from the primary interface spec (#6964)
* fix(ec2): read RunInstances security groups from the primary interface spec RunInstances read security groups only from the top-level SecurityGroupId.N. With private_ip or associate_public_ip_address set, Terraform's aws_instance sends them on the primary interface spec (NetworkInterface.1.SecurityGroupId.N), so the instance landed in the VPC's default group and the next plan wanted to replace it. The interface spec's groups apply only when its DeviceIndex is 0 (another index is a secondary interface), and a request carrying both shapes fails with InvalidParameterCombination, as on AWS. * test(ec2): match the capacity reservation argument RunInstances now passes * test(ec2): fold the interface security group cases into Ec2RunInstancesPublicIpParamTest Both classes tested what RunInstances takes from the interface spec with the same handler setup, base params and runInstances stub; only the captured argument differed. One forward() helper now runs the request and captures both the security groups and the public-IP override, and the separate class is gone. |
||
|
|
d68876edcc |
fix(ec2): ignore ports when revoking an all-traffic rule (#6895)
* fix(ec2): ignore ports when revoking an all-traffic rule Revoking an "all traffic" (-1) rule compared ports literally. Terraform's aws_security_group revokes AWS's default egress rule as -1 with FromPort=0 and ToPort=0, which never matched the stored rule (it has no ports), so every new group kept allowing all egress and the next plan wanted to remove it again. AWS ignores ports for -1. Protocols are now compared after the same normalization the security-group evaluation uses, so a revoke naming protocol 6 also matches a tcp rule, as on AWS. * test(ec2): name the all-traffic revoke test a service test * test(ec2): move the all-traffic revoke tests into Ec2ServiceTest Use Ec2ServiceTest's existing mockModeService() instead of a copied mock-mode harness, as requested in review. |
||
|
|
1356cbbc84 | fix(core): bind the DB proxies and EC2 port forwards with a 4096 backlog (#6744) | ||
|
|
8ececd84b4 |
fix(ec2): keep the tags CreateFlowLogs is given (#6890)
* fix(ec2): keep the tags CreateFlowLogs is given CreateFlowLogs dropped its vpc-flow-log TagSpecification, and DescribeFlowLogs had no tagSet, so Terraform's aws_flow_log tags never read back and every plan after apply wanted to add them again. The tags are now stored with the flow log and returned. * test(ec2): read a flow log's tags back through the AWS SDK |
||
|
|
0e87e6f1de |
fix(ec2): let a systemd guest's init start sshd (#6882)
Floci started /usr/sbin/sshd itself in every guest, including systemd ones whose image starts sshd from its own unit at boot. The two raced for port 22: if Floci's won, ssh.service failed, and the stray daemon outside systemd kept the port, so a later `systemctl restart ssh` (to apply an sshd_config change, as user data commonly does) failed too. On EC2 the AMI's init alone starts sshd; systemd guests now work the same way. |
||
|
|
3f36c4e99e |
fix(ec2): record EbsOptimized from RunInstances (#6875)
* fix(ec2): record EbsOptimized from RunInstances RunInstances dropped EbsOptimized, so an aws_instance with ebs_optimized = true read back false and Terraform replaced it on every plan. The request's value, else the launch template's, is now recorded on each launched instance. It is applied after the launch on the RunInstances API path only; instances launched by CloudFormation, Auto Scaling or Fleet still report false (documented). * test(ec2): clean up the launch template and each instance if a launch fails The launch-template case launched both instances before its cleanup scope opened, so a failed launch leaked the template and, on the second launch, the first instance. |
||
|
|
d7763fff8e |
fix(ec2): honor DryRun when creating VPCs, subnets and security groups (#6823)
* fix(ec2): honor DryRun when creating VPCs, subnets and security groups CreateVpc, CreateSubnet and CreateSecurityGroup never read DryRun, so a dry run created the resource it asked about. A real CreateVpc that followed left a second VPC, and the real create of a subnet or group failed: InvalidSubnet.Conflict for the subnet's CIDR block, InvalidGroup.Duplicate for the group name. Each handler now answers DryRunOperation (HTTP 412) and creates nothing. It answers after parsing the tag specifications and, for CreateSecurityGroup, reading the required GroupName and GroupDescription. Ec2Service makes every other check, so a dry run is answered before the VPC id, the VPC, the CIDR block, the tenancy, overlap with other subnets or a taken group name are checked. AWS documents no order for those checks. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): look up the VPC before answering a subnet or group dry run A DryRun CreateSubnet or CreateSecurityGroup naming a VPC that does not exist answered DryRunOperation, "would have succeeded", while the real create fails with InvalidVpcID.NotFound. CreateSubnet without a VpcId answered DryRunOperation too, where the real create gives MissingParameter. The handlers now require the VpcId and look up the VPC, the default one for a security group without a VpcId, before they answer the dry run. A RunInstances dry run already keeps the error of a missing subnet or group, and the Service Authorization Reference lists the VPC, with its tags and tenancy, in both actions' permissions. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): share the security group VPC lookup with its dry run The CreateSecurityGroup handler and Ec2Service each picked the group's VPC, the named one or the region's default, so the two copies could drift. Ec2Service.requireSecurityGroupVpc now does it for both, and the CreateSubnet handler looks up the VpcId it has just required. New tests cover a group dry run with an absent or empty VpcId, which is answered for the default VPC, and a group dry run in a missing VPC through the SDK. The comments and docs now name every check a dry run skips, the zone and the IPv6 block included, and link the Service Authorization Reference. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * docs(ec2): list the errors a create dry run still returns The CreateVpc, CreateSubnet and CreateSecurityGroup rows said which checks a dry run skips but not which errors it keeps. They now say that a tag specification error, and a missing VpcId, GroupName, GroupDescription or VPC, comes back on a dry run too, and that an empty VpcId also puts a security group in the default VPC. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): keep tag errors ahead of the create dry-run answer CreateVpc, CreateSubnet and CreateSecurityGroup read their tag specifications before they answer DryRun, so a reserved aws: key is still rejected on a dry run, as the EC2 docs page says. A handler test now pins that for all three actions; it fails if the dry-run answer is moved ahead of the tag parsing. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): use the shared EC2 request helper in the dry-run test Ec2CreateDryRunIntegrationTest now calls Ec2Requests.ec2 with "test" and "us-east-1" instead of its own copy of that helper. The comments in the CreateSubnet and CreateSecurityGroup handlers shrink to one line each; docs/services/ec2.md already explains the order. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> |
||
|
|
a83fa9c9e4 |
fix(ec2): keep the KMS key a volume is created with (#6756)
* fix(ec2): keep the KMS key a volume is created with CreateVolume ignored KmsKeyId, so neither CreateVolume nor DescribeVolumes reported kmsKeyId, even for a volume created encrypted with a named key. A volume CreateVolume makes encrypted now keeps the request's KmsKeyId as given, or gets the region's default EBS key when it names none, and both responses report it. A volume that is not encrypted keeps no key, and volumes stored before this change load as they were, with no kmsKeyId. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): read volume responses with XmlParser The volume KMS key tests read CreateVolume and DescribeVolumes responses with a regular expression, substring offsets and plain string matches. They now read them with XmlParser, as other EC2 tests do, so element values are parsed and decoded as XML. Test-only; the assertions are unchanged. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): keep the KMS key a launch's block device mapping names A launch's encrypted volumes got the region's default EBS key even when their block device mapping, or the launch template's, named Ebs.KmsKeyId. The key now goes from the mapping to the volume, root included, and a mapping that names none still gets the default. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): pin the launch volume key rules Pin that a launch mapping naming a key without Encrypted leaves the volume unencrypted and keyless, and that a request entry's key wins over its launch template's. Delete the test's launch template, reuse the launch helpers in the root-volume test, and document that a launch volume encrypted only by its snapshot gets the region's default key, since snapshots record no key. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> |
||
|
|
b5033e970d |
fix(ec2): model scheduled capacity reservations (#6764)
* fix(ec2): reject unsupported future capacity reservations Reject StartDate before capacity reservation creation or client-token replay. Preserve immediate reservation behavior. Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> * fix(ec2): model scheduled capacity reservations Retain future start and commitment metadata, activate through capacity reconciliation, and preserve client-token replay. Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> * fix(ec2): preserve activation membership and replay tags Reuse open-reservation instance matching during activation, persist creation tag identity, and keep replay from overwriting later tag edits. Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> * fix(ec2): validate future reservation matching and capacity Require targeted matching, supported instance families and at least 32 vCPUs before future reservation publication. Preserve scheduling, tag replay and immediate reservation behavior. Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> --------- Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
1a5decbb4a |
fix(ec2): honor default subnet filters (#6772)
Handle both documented default-subnet filter aliases and preserve safe asynchronous ENI cleanup. Signed-off-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
65df465fc3 |
fix(ec2): create the EBS volumes a launch's block device mappings describe (#6734)
* fix(ec2): create the EBS volumes a launch's block device mappings describe RunInstances gave every instance one 8 GiB root at /dev/xvda and took only the root's VolumeType from its block device mappings. Launches now plan their volumes before anything is stored: the AMI's mappings, or an 8 GiB root when it maps none, with the launch's own entries merged over them field by field, under either spelling of a device. The instance is rooted at the AMI's RootDeviceName. NoDevice removes an AMI device and a VirtualName entry takes one over, never the root. Snapshot sizes apply, a smaller size, a missing snapshot, a missing or invalid device name and a device named twice are refused with nothing stored, and IOPS and throughput are kept only for the types that take them. DescribeInstances lists every attached volume with its own state and DeleteOnTermination, and termination treats the root like any other volume. Volume reads settle attachments to an instance that ended terminated without TerminateInstances, as a failed container launch does. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): delete every volume of a launch that is rolled back A launch undone after its instances were stored, an instant CreateFleet whose later launch fails or a RunInstances whose capacity reservation was taken in the meantime, terminated its instances. Termination keeps the volumes whose DeleteOnTermination is false, so the refused launch left them behind as available. Each launch now records the volumes it creates on its reservation, and the rollback deletes those termination left unattached. The ids do not depend on attachments, which a read can end first when a failed container's volumes are settled. DeleteOnTermination is never changed, so an instance whose termination fails keeps its volumes as they were, and a volume attached to another instance since stays. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): size a snapshot-only root from its snapshot For an AMI that maps no root device, the launch gave the root a fallback 8 GiB size before merging the launch's own entries, so a root entry naming only Ebs.SnapshotId kept that size and a larger snapshot was refused with InvalidBlockDeviceMapping. The fallback size now applies only after the merge, when the root names neither a size nor a snapshot. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * perf(ec2): read volume attachments once per DescribeInstances Listing an instance's block device mapping scanned the whole volume store, once for every instance in a RunInstances or DescribeInstances response. The attachments of all the response's instances are now gathered in one scan per region and looked up per instance. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> |
||
|
|
9e14ffe92a | fix(ec2): keep Ipv6CidrBlock and IcmpTypeCode on network ACL entries (#6680) | ||
|
|
986117a45c |
fix(ec2): keep key pair names unique under concurrent requests (#6635)
* fix(ec2): keep key pair names unique under concurrent requests CreateKeyPair and ImportKeyPair checked that a name was free and stored the new key pair as two separate steps, so two requests for one name at the same moment could both pass the check and both store a key pair. Both got a key pair back, DescribeKeyPairs listed the name twice, and RunInstances injected whichever record it found first, so the other caller's private key did not open the instance. CreateKeyPair generates its key between the two steps, which keeps that window open for as long as key generation takes. Both actions now store through one method that checks the name again and writes under the EC2 service's striped lock for the region and name, so the second request is refused with InvalidKeyPair.Duplicate and the same message as before. The first check stays where it was, so a single request is answered as before, and a taken name is still refused before a key is generated for it. Follow-up to the review of #6112. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): keep a tag write from restoring a deleted key pair A CreateTags on a key pair reads the record and writes it back with its new tags while holding the key pair's lock, but DeleteKeyPair deleted without that lock. A delete landing between the read and the write was undone: the key pair came back, and if a CreateKeyPair had taken the freed name in between, the name then had two key pairs. DeleteKeyPair now deletes each matching key pair under the lock tag writes take on it, as DeleteEgressOnlyInternetGateway does, so a tag write either finishes before the delete or finds the key pair gone. The EC2 docs now say what CreateKeyPair and ImportKeyPair do with a taken name rather than promising one key pair per name outright. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): pin where the key pair race tests wait, and clean up the SDK test The race tests now let the held write go early only when the waiting request is blocked in storeNewKeyPair or deleteKeyPair on a monitor the held request owns, and otherwise wait for that request to finish, so a change that made it wait anywhere else fails the test instead of quietly skipping the check under the lock. The SDK test waits up to 60 s for its requests to finish before it deletes the name, so a slow request is not left to store a key pair after the cleanup, and it checks the refused requests' error code and status but not their message, which AWS words differently from Floci. The storeNewKeyPair Javadoc also says that the store's own locks, taken inside the name lock, never lead back to an EC2 lock. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): name what the key pair race tests wait for A race test whose request comes to wait anywhere other than the named Ec2Service method now fails with a timeout that says what it waited for, and the helper says why the method is named. The DeleteKeyPair comment says that scan returns a new list rather than copies, and the SDK test's cleanup comment says it waits up to 60 s. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): say what pinning the waiting method guards against The race tests' helper Javadoc no longer says that a wait elsewhere always skips the code under the lock: such a wait may not be at the lock under test, so the tests time out rather than pass without exercising it, and moving that lock into another method means updating the name the tests give. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): park the key pair race tests' writes with ParkingStore Both race tests held a write on a latch in an anonymous store of their own. They now wrap the shared testing ParkingStore in AccountAwareStorageBackend, as the Config tagging tests do, and arm its next write: before the first request in the name race test, and after the key pair is created in the delete test, so the write it parks is the tag write's. The name race test creates ED25519 keys so that key generation stays well inside ParkingStore's two-second wait. Main code is unchanged. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> |
||
|
|
0634184f5e | fix(ec2): apply TagSpecification on key pair, network ACL and image creates (#6551) | ||
|
|
f1816dbb44 |
fix(ec2): disable Nagle on both socat sockets of a published port forward (#6572)
socat relayed a client's second small write only after the first was acknowledged, so delayed ACKs stretched every PostgreSQL statement close to ~44 ms. Add nodelay (TCP_NODELAY) to both addresses: the listener's option reaches the accepted socket in the fork child, and the connect side covers the instance-facing one. Closes #6176 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> |
||
|
|
60ef203fa8 | fix(ec2): launch instances into capacity reservation groups (#6404) | ||
|
|
4a95c1bb95 |
feat(ec2): support DHCP options lifecycle (#6428)
* feat(ec2): support DHCP options lifecycle * fix(ec2): validate DHCP options lifecycle edge cases * fix(ec2): reuse region-aware private DNS domain for DHCP defaults * fix(ec2): isolate DHCP options review regressions |
||
|
|
307380750f |
feat(ec2): configure additional AWS-managed prefix lists (#6401)
Load an opt-in regional catalog when EC2 is enabled, canonicalize and validate its IPv4 entries, and reuse the read-only discovery and security-group paths. Resolve AWS-managed CIDRs for policy evaluation and firewall generation alongside customer-managed lists. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
5b24703815 |
fix(ec2): normalize subnet IPv6 CIDRs and expose zone network borders (#6387)
Normalize subnet IPv6 responses and expose regional availability-zone network borders. Keep the read-only regional test at a unique execution order. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
f7c9d9a993 |
fix(ec2): pin Rocky 10 runtime to advertised release (#6379)
Pin the Rocky 10 backing image to the release already advertised by its catalog identity and documentation. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
d2f06bdd5b |
fix(ec2): align Rocky 9 runtime with advertised release (#6377)
The configured Rocky 9 image reports 9.3, while the catalog advertises 9.6. Use the explicitly versioned Rocky image and update the documented mapping. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
81d399a1ed |
fix(ec2): honor capacity-reservations-only launches (#6354)
Require reserved capacity for direct, template, Fleet and Auto Scaling launches. Preserve the targeted shortage message shared with restart. Keep CloudFormation timeout fixtures in their separate contribution. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
5182449625 |
fix(ec2): report targeted reservation capacity exhaustion (#6344)
Return ReservationCapacityExceeded when a matching targeted reservation lacks capacity at precheck or admission, including restart. Preserve mismatch errors and existing resource cleanup. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
d05399feb1 |
feat(ec2): associate instances with capacity reservations (#6336)
Associate eligible instances with capacity reservations across EC2, AutoScaling and CloudFormation. Preserve account ownership, rollback, physical stop/start ordering and bounded targeted quota admission. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> |
||
|
|
bc760f743d | fix(ec2): list requested launch template versions (#6329) | ||
|
|
d3c2dbb1d9 |
fix(ec2): skip addresses stored resources hold when the VPC network allocates (#6284)
* fix(ec2): skip addresses stored resources hold when the VPC network allocates The VPC network's allocator reads only its lease table, but a launch that names an address while a failed launch is still giving it back keeps the address without a lease, and so does a network interface created with its own address. assignPrivateIp now asks for another address while the one it got is held by a stored instance, network interface or NAT gateway in any account, so a later launch's Docker attach no longer fails on an address that is already in use. The addresses it walks past are given back once it is done, since their holders took no lease of their own. Closes #6283 * fix(ec2): keep the fallback off addresses the VPC network walk skipped When the walk past held addresses runs the Docker-backed allocator dry, the synthesised fallback checked only the caller's account, so on a shared default subnet it could hand out the address another account's resource holds. It now skips the addresses the walk found held as well. * test(ec2): share the mocked-network and RequestContext setup in Ec2ServiceTest requestContexts builds the RequestContext CDI mock that four helpers and tests each built for themselves, and mockedVpcNetworkService replaces the mock-mode new Ec2Service(..., vpcNetworks) the private-address tests repeated. The comment on why jakarta.enterprise.inject.Instance is written out in full lives in requestContexts. |
||
|
|
8d73535826 |
feat(ec2): list SUSE and Red Hat family images in the image catalog (#6193)
The EC2 image catalog carries the SUSE family (SLES, SLES for SAP, SUSE Multi-Linux Manager and openSUSE Leap) and the Red Hat family (RHEL and Rocky Linux) under their publishers' owner ids. DescribeImages finds each by owner and name. |
||
|
|
7c202a8966 |
fix(ec2): AND repeated filter names on every Describe action (#6170)
* fix(ec2): AND repeated filter names on every Describe action The Query handler read Filter.N into a map keyed by name, so a filter whose name was already given replaced the earlier one: tag-key=Env with tag-key=Team matched every resource tagged Team, and two vpc-id filters naming different VPCs matched the second VPC's resources. AWS joins every filter with an AND, a repeated name included. Every Describe action that reads Filter.N now passes the filters in request order to the service, as DescribeKeyPairs, DescribeTags and DescribeAvailabilityZones already did, and each filter narrows the answer the way a lone filter of that name does. The service keeps its map overloads for the callers that build filters of distinct names in code; they delegate to the ordered overloads, so what they get back does not change. DescribeImages builds its lookup image from the first name wildcard and returns it only when it satisfies every filter. Four existing tests passed null or any() as the filters of a method that now has a second overload. They pass Map.of() or anyMap() instead, which is what the code under test sends. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): sweep transit gateway peering attachments for repeated filters DescribeTransitGatewayPeeringAttachments goes through the same shared matcher as the other actions the parameterized tag-key case covers, but had no case of its own. It now has one: two tag-key filters find only the peering attachment that carries both keys. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): satisfy every repeated filter when building a lookup image With a filter name given twice, DescribeImages built the image it synthesizes for an unmatched lookup from the first name wildcard and the first concrete value of each other filter, so a later filter of the same name could reject it and the lookup came back empty: architecture with x86_64 or arm64 and architecture with arm64 returned nothing. Each name filter now offers its wildcard in turn, and each other value is the first one that every filter of its name admits. A lone filter of each name still yields the one image it always did. DescribeInstanceTypeOfferings kept the types of its InstanceType.N parameter only through the first instance-type filter, so repeating that filter dropped them. They are now kept beside the types that every instance-type filter names. The docs say "an action" rather than "a Describe action", since the Get and Search actions that read Filter.N are covered too. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): let an instance-type filter without values narrow nothing DescribeInstanceTypeOfferings looked up the types its first instance-type filter named, so a first filter without values limited the answer to the InstanceType.N types while a later one without values narrowed nothing: the answer depended on the order of the filters. A filter without values now names and narrows nothing wherever it stands, as a lone one never added a type. The lookup image of DescribeImages tries the first wildcard of each name filter, which the comment now says. Every filter value the image is built from is tested by the image matchers' own rule. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * refactor(ec2): name the per-filter checks of repeated filters The test that every filter of one name admits a value was written out by hand at each site. Two helpers beside everyFilterAdmits now carry it: everyFilterContains, for exact values where a filter without values admits anything (security group rules, prefix lists, the later instance-type filters of DescribeInstanceTypeOfferings), and everyFilterMatches, for values with wildcards where a filter without values matches nothing (the location filters of offerings, and the spot-price and timestamp filters of DescribeSpotPriceHistory). No answer changes. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): match instance-type wildcards in DescribeInstanceTypeOfferings AWS takes * and ? in an instance-type filter value of DescribeInstanceTypeOfferings (the CLI reference filters on c5*), but Floci looked each value up by its exact name, so a lone t3.* found nothing and t3.* beside t3.micro found nothing either. A first filter holding a wildcard now looks up the whole catalog, and every filter matches a type with the same matcher as the location filter. Exact values give the same answer as before. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): pin an empty lookup for overlapping name patterns Two name filters foo-* and *-bar-* overlap, but the image built from the first wildcard of each breaks the other filter. DescribeImages returns no image here, as AWS returns only images that exist; before the filters were ANDed it returned one that broke foo-*. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): match offerings instance-type values with the linear glob The instance-type wildcards of DescribeInstanceTypeOfferings went through the regex matcher, which backtracks on a caller-supplied pattern of many stars: twenty stars took about sixteen seconds per request. They now go through everyFilterAdmits, the two-pointer glob the image filters already use. Value-less filters are dropped before the check, so no answer changes. Also reword a test comment. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): name the matcher a many-star pattern goes through The glob that matches instance-type values is a two-pointer match, not a strictly linear one, so the test's Javadoc says that instead. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> |
||
|
|
ff813c6f34 |
fix(ec2): create the key type and format CreateKeyPair asks for (#6112)
* fix(ec2): create the key type and format CreateKeyPair asks for CreateKeyPair ignored KeyType and KeyFormat, so asking for an ED25519 key or a PuTTY key file returned a 2048-bit RSA key as PEM, and any value of either was accepted. Now, as AWS answers: - KeyType=ed25519 creates an ED25519 key, returned in OpenSSH's own BEGIN OPENSSH PRIVATE KEY format and fingerprinted by the padded base64 SHA-256 of its public key blob. - KeyFormat=ppk returns the key as an unencrypted PuTTY version 2 key file whose comment is the key pair's name. An RSA key keeps the SHA-1 fingerprint of its DER private key, taken over the key with its larger prime first, the order PuTTY stores. - Any other KeyType or KeyFormat is InvalidParameterValue with AWS's validation message, checked before the name is found taken, and nothing is created. RunInstances injects the ED25519 public key of such a key pair, and DescribeKeyPairs reports it. Follow-up to the review of #6093. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): keep the CreateKeyPair test helpers in one place The launch test and the key unit tests use the Query helpers and the ED25519 readers of Ec2CreateKeyPairIntegrationTest instead of their own, PuttyKeyFile reads fields and RSA public keys with SshPublicKeys, the digests come from Digests, and the RSA prime-order test takes its keys from Ec2KeyMaterial.generateRsa instead of building them itself. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): answer a CreateKeyPair DryRun before its other checks AWS answers CreateKeyPair with DryRun=true by DryRunOperation (412) before it looks at the name or the key type, so a DryRun with an unknown KeyType is DryRunOperation rather than InvalidParameterValue. Floci ignored DryRun and created the key pair; it now answers it first and creates nothing. The CreateKeyPair tests share their requests and key readers through Ec2CreateKeyPairFixtures rather than an integration test class, the launch test shares the container-backed application of Ec2CapturedImageReclaimIntegrationTest, a described public key is compared without the line break AWS ends it with, a created ED25519 key imports with the same fingerprint, the PuTTY comment rule is checked for CR, tab and DEL as well as LF, and the case of a key with its smaller prime first is skipped rather than failed under a generator that never makes one. The orders AWS documents nowhere are described as Floci's. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): clean up after the CreateKeyPair tests The launch test terminates its instance and deletes its key pair, since it now shares an application with another class, and the import test deletes what it made even when a step before its assertion fails. A test comment and the DryRun comment no longer claim an order AWS does not document. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): say what the launch test's cleanup leaves behind With the container manager mocked, TerminateInstances releases the instance's address and volume but leaves its record pending, so the comment says so instead of claiming the instance goes. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): record the key type CreateKeyPair created With #6093 merged, CreateKeyPair stored every key pair's type as rsa, so an ED25519 key pair was described as rsa and the key-type filter found it under rsa. It now stores the type it created. The guard test now requires the reported type and checks the key-type filter. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): share Ec2KeyPairFixtures and keep the type check to what AWS does The CreateKeyPair tests now use the key pair fixture #6093 added, which gains the type-and-format CreateKeyPair and the ED25519 key readers, and their own fixture class goes. The described-type check no longer looks the key pair up with the key-type filter, which AWS answers with InvalidParameterValue. The createKeyPair Javadoc says the name is checked as present and valid before the values. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): read a stored key pair's type from its public key A key pair saved before its type was recorded was described as rsa whenever it held key material, which would misreport a created ED25519 key pair. Its type is now read from its stored public key, created or imported; a created key pair saved before Floci kept its public key is still rsa, the only type CreateKeyPair made then. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * refactor(ec2): generate ED25519 key pairs in Ec2KeyMaterial Ec2KeyMaterial already reads imported ED25519 keys, so the created ones move there too and share its base64 and fingerprint rule instead of a class of their own. Ec2PuttyKeys uses its colon-hex fingerprint, and the PuTTY test key moves into Ec2KeyPairFixtures with the other test keys. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): check the described key type through the SDK The SDK test now checks DescribeKeyPairs returns the type each key pair was created with, which the hardcoded rsa would have failed. The key pair fixture exports the region it signs for, and the legacy keyType paragraph in the EC2 docs is re-wrapped. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> |
||
|
|
fbf3bfff84 |
fix(ec2): refuse key pairs AWS refuses and describe their type, create time and filters (#6093)
* fix(ec2): refuse key pairs AWS refuses and describe their type, create time and filters ImportKeyPair stored whatever material it was given. It now reads the key as AWS documents: RSA or ED25519 as an OpenSSH line, RSA also as RFC 4716 or base64 DER, bare or in PEM armour, and RSA from 1024 to 16384 bits. DSA, ECDSA, security-key and certificate keys, blobs that are incomplete, carry trailing bytes or name another type, and material with more than one key line are refused with InvalidKey.Format. The key is stored as one OpenSSH line, which is what RunInstances writes to authorized_keys. CreateKeyPair and ImportKeyPair take a KeyName of up to 255 ASCII characters with no leading or trailing space, and answer any other with InvalidParameterValue. DescribeKeyPairs now returns keyType and createTime, and honours Filter.N with key-pair-id, key-name, fingerprint, key-type, tag-key and tag:<key>, refusing any other name. Key pairs persisted before this change load as they are: they have no createTime, and their keyType is read from the stored key. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): describe malformed key pairs from saved records, not imports ImportKeyPair now refuses material that is not exactly one whole key and converts RFC 4716, so the IncludePublicKey cases that imported partial or mislabelled blobs, trailing bytes, two key lines or UTF-16 text could no longer create their key pairs. Such material is now held only by key pairs saved by an earlier version, so those cases describe a stored record through the handler instead, and the RFC 4716 case checks that the converted key is described as its OpenSSH line. The handler test stubs the DescribeKeyPairs overload that takes filters, which the handler now calls. The Key Pairs docs and the javadoc of the public-key description say what is stored now and what an older record may still hold. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): refuse a DER key whose bit string declares pad bits A SubjectPublicKeyInfo whose key BIT STRING declares unused bits made Bouncy Castle throw an IllegalStateException, which the key reader did not catch. ImportKeyPair answered such base64 DER or PEM with a 500 instead of InvalidKey.Format, and a key pair saved earlier with that material failed every DescribeKeyPairs in its region, since the key type of an older record is read from its material. The reader now refuses a key bit string with pad bits, and treats Bouncy Castle's IllegalStateException like its other parse errors. A new test sets every byte of each binary form to values that matter to DER and SSH framing and checks that nothing escapes. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): refuse an IncludePublicKey that is neither true nor false DescribeKeyPairs read IncludePublicKey with Boolean.parseBoolean, so a value such as "invalid" or "yes" was taken as false and the key pairs were described without their public keys instead of the request being refused. It now goes through the handler's strict boolean reader, the one the block device mapping and peering options use: true or false in any case, and InvalidParameterValue for anything else. TRUE was already read as true, and still is. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): send each describe filter once and allow clock skew in the SDK check The DescribeKeyPairs integration helper always sent a key-name filter of the test's prefix, so the cases that test key-name itself sent the name twice and Floci kept only the second. A key-name filter under test is now sent alone. The SDK compatibility check gives createTime a minute either side, since Floci may run in a container with another clock. The Key Pairs docs and the RSA length test now say what AWS lists and what Floci takes beyond it, citing the 8192-bit key AWS was seen to import. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): refuse a DER key with no key in its bit string An rsaEncryption SubjectPublicKeyInfo whose key bit string holds no bytes parses to no structure at all, and the reader passed that null on to a NullPointerException: ImportKeyPair answered such DER or PEM with a 500, and a key pair saved earlier with it failed DescribeKeyPairs for every listing that included it. The reader now reads the PKCS#1 sequence itself and refuses anything that is not two integers. It reads those integers signed, as an ssh-rsa blob's are, so a modulus missing its sign byte is refused rather than imported as a different, positive key. And the key type of an older record no longer depends on the reader never failing: if it does, the type is left out and the failure logged, instead of failing the whole description. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * docs(ec2): keep key pair comments and docs true to the new checks SshPublicKeyException's javadoc said EC2 answers an unreadable imported key with no fingerprint; ImportKeyPair now refuses it with InvalidKey.Format. The Key Pairs docs say that an empty IncludePublicKey reads as false. The RSA length test links the report of an 8192-bit import in full, and the describe test says that sending one key-name filter is a Floci limit, not an AWS rule. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): cover the stored key-type guard on its own The stored-record test passed even with the reader broken, because the guard in keyTypeOf turned the reader's exception into the expected missing type. It now checks that the reader refuses each stored material by itself, and a new test makes the reader fail, through an inline static mock as other tests here do, and checks that the record is still described, with no type, and that a key-type filter passes over it. The keyTypeOf javadoc and the docs now mention that case, the docs say a blank IncludePublicKey reads as false and a missing or blank KeyName is MissingParameter, and a comment no longer says every imported key is fingerprinted with MD5. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): make the stored key-type guard test depend on its failing reader The guard test stored text the real reader already refuses without throwing, so it passed even if the failing reader was never consulted. It now stores a valid ed25519 key, whose type would be ed25519 without the failure, checks that the stubbed reader was called, and describes the record through the handler too, where each item's type is read. A comment on the stored-record test no longer says the reader refuses the records it accepts. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * fix(ec2): AND a repeated DescribeKeyPairs filter name DescribeKeyPairs read Filter.N into a map keyed by name, so a second filter of one name replaced the first: key-name=X-prod-* with key-name=X-*-web returned X-dev-web too. AWS joins every filter with AND. The handler now passes the filters in request order, as DescribeAvailabilityZones already does, and a key pair has to match each of them, with the values of one filter still ORed. The other EC2 describe actions share the map reader and keep its behaviour; that is for a separate change. The describe test's helper goes back to ANDing a second key-name filter with its prefix filter. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): show the key-type guard covers only key pairs saved without a type With the key reader made to fail, ImportKeyPair still fails with the error, and a key pair whose type was recorded is described and filtered by key-type without the reader being consulted. Only a record saved before the type was recorded goes through the guard that leaves its type out and logs the failure. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): check repeated key pair filters in the service, and route unfiltered calls through them A service test now passes Filter.N with a repeated name to the ordered DescribeKeyPairs overload and checks that the two filters are ANDed, and that a later unknown name is still refused. The unfiltered overload goes through the ordered one too, leaving the map form as a convenience for filters of distinct names, and the docs sentence on filters is split in two. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): pick repeated key pair filters that each match more alone The service check of a repeated key-name filter used `*-rsa` then `g*`, and `g*` alone gives the same answer, so it passed when only the last filter was kept. Each filter now matches two key pairs alone and one together, so keeping either one instead fails the test. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): share one fixture between the key pair tests The import, describe and public-key integration tests each had their own CreateKeyPair, ImportKeyPair and DeleteKeyPair calls, and the same ED25519 key was pasted into five classes. Ec2KeyPairFixtures now holds those calls and the one key, which the handler, service and persistence tests use too. SshKeyBlobs builds the OpenSSH blobs and lines that SshPublicKeysTest, Ec2KeyMaterialTest and Ec2QueryHandlerTest each built and joined themselves, and the import test reads RSA keys with SshPublicKeys.rsaKeyOf instead of its own copy. Test-only: every class runs the same tests as before. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): build key blobs with the SshPublicKeysTest helpers main has SshPublicKeysTest on main already builds OpenSSH blobs with blob and joins bytes with withTrailing. The EC2 key pair tests now call those two, made public for them, instead of the SshKeyBlobs class the previous commit added, which is removed. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> * test(ec2): keep the shared throwaway keys in Ec2KeyPairFixtures The pinned RSA key and its fingerprint, the ED25519 fingerprint, the DSA and ECDSA P-256 keys and the truncated ssh-rsa blob were each written out in two to four of the key pair test classes. They now live beside the ED25519 key in Ec2KeyPairFixtures; keys only Ec2KeyMaterialTest uses stay there. The handler test loses a comment and an import the earlier move left behind. The earlier move also switched Ec2KeyPairPublicKeyIntegrationTest and Ec2QueryHandlerTest from the ED25519 key #6055 added to the shared one; no assertion in them depends on which valid key it is. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> --------- Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> |
||
|
|
e5591dda32 |
feat(ec2): page and filter DescribeTags as AWS does (#6109)
* feat(ec2): page and filter DescribeTags as AWS does DescribeTags ignored MaxResults and NextToken, so SDK paginators got a single page, and matched filter values exactly: tag:<key> was dropped, the * and ? wildcards matched literally, and a filter name given twice kept only the last one. It now pages with MaxResults (5 to 1000, InvalidMaxResults otherwise) and NextToken, takes tag:<key> as the documented alternate spelling of a key filter plus a value filter, honours wildcards, ORs the values of one filter and ANDs separate filters. Results are ordered by resource id so a page boundary stays put while no tags change. Signed-off-by: Hector Ventura <hectorvent@gmail.com> * fix(ec2): bound filter wildcards and refuse every out-of-range MaxResults EC2 filter wildcards were translated to a regex, so a caller-supplied pattern of many stars backtracked for seconds against a long value and `*` skipped line terminators. They now use the two-pointer glob IAM and S3 already share, which every EC2 Describe filter goes through. DescribeTags treated MaxResults=0 and negative values as unpaged; any value sent outside 5 to 1000 now answers InvalidMaxResults, and only a missing MaxResults is unpaged. A NextToken whose offset is at or past the end returns an empty last page instead of overflowing into a token that fails on the next call. The compat case moves to its own @Order. Signed-off-by: Hector Ventura <hectorvent@gmail.com> --------- Signed-off-by: Hector Ventura <hectorvent@gmail.com> |