An ENI could have IPv6 addresses assigned while its top-level
ipv6Address was missing from CreateNetworkInterface and
DescribeNetworkInterfaces. The shared serializer now reports the first
assigned address there, keeps the ipv6AddressesSet list, and omits the
field when the interface has none.
Ported from Emanuel Aseghehey's AndreKurait/floci#1239.
DescribeManagedPrefixLists and GetManagedPrefixListEntries now include the AWS-managed com.amazonaws.global.cloudfront.origin-facing list (pl-3b927c52) with the 49 CLOUDFRONT_ORIGIN_FACING IPv4 ranges of ip-ranges.json, in commercial-partition regions only; China, GovCloud and the other partitions keep only the S3 and DynamoDB lists, and an accepted unknown region takes the deployment's partition. Like those lists, its MaxEntries is its entry count; the security-group rule quota is tracked in #8790. A prefix-list catalog that already declares the list keeps loading, the built-in list serving it.
Closes#8634
* fix(ec2): settle interrupted lifecycle states and prune terminated instances
* fix(ec2): address review findings on lifecycle recovery and pruning
* test(ec2): use Awaitility in the EC2 lifecycle tests
DescribeInstanceTypes now knows 61 virtual sizes of M7a, M8a, M7i, M8i, C7a and C7i, captured in us-east-1 on 2026-11-17: their vCPUs, memory, x86_64 architecture, AMD or Intel manufacturer and network limits, 24xlarge and 48xlarge included. One integration test checks both the Graviton and the x86 captures through the API, and the catalog inventory takes its expected names from those captures.
Closes#8755
On AWS a function's Hyperplane network interfaces sit in the subnets
its VpcConfig names, and EC2 refuses DeleteSubnet, and so DeleteVpc,
while one is there. Floci's Lambda never told EC2 a function used a
subnet, so DeleteSubnet succeeded under a VPC-configured function and
left it naming a subnet that was gone.
- LambdaService is a VpcDependencyProvider: a function of the caller's
account, or a published version of one, holds each subnet its
VpcConfig names and the VPC it is configured in
(LambdaFunctionStore.listWithVersionsForAccount, which also reads a
record stored before accounts were kept apart, unprefixed until it
is next read).
- CreateFunction and UpdateFunctionConfiguration save a function that
names subnets under EC2's subnet lock, so a DeleteSubnet either sees
it or runs before it is stored. A VpcConfig the request set is
resolved again under the lock, so a subnet deleted since the request
was validated is unknown, as one never created is, and the function
infers no VPC from it.
ECS awsvpc tasks already hold their subnet through the network
interface each task is given, which DeleteSubnet counts.
LambdaVpcResourceValidationIntegrationTest has DeleteSubnet refused
under a function, then under its published version once $LATEST moves
to another subnet, and allowed once the version is deleted, and a
subnet deleted while a function is created leaves it no inferred VPC.
LambdaFunctionStoreAccountScopeTest covers the unprefixed record.
ec2.md and lambda.md say so.
With security-group enforcement on, the socat publisher was switched
off, so an application port a security group opened was never reachable
from the host. Docker can replace a host client's address (Docker
Desktop shows every client as its gateway), so no rule narrower than the
whole internet can be judged on it.
Host-published access now counts as traffic from outside the VPC: with
enforcement on, a port is published only when an ingress rule opens it
to 0.0.0.0/0, or failing that ::/0, which admit a client whatever
address it arrives with. The sidecar dials the instance through its
protected namespace's helper, on the helper's network: on its IPv4
address, or on its Docker IPv6 address for a port only ::/0 opens, which
is not published on a network without IPv6. A client's family is still
seen on the host, so a port only one family's rule opens binds only that
family's host addresses. A port whose rules move family is republished,
the family is persisted for restore, and a restart brings each running
instance's forwards in line with its current rules. Ports opened after
launch publish and revoking removes them, as with enforcement off; a
port only a narrower CIDR, a prefix list or a group reference opens
stays reachable on the direct container path.
Also brings Ec2ServiceTest's never-allocates check onto the
three-argument allocatePrivateIp that #8598 introduced, which left
main's tests not compiling after #8576.
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.
With security-group enforcement on, a managed ENI's identity was its
IPv4 address alone, so a rule naming an IPv6 range never matched a peer
on the IPv6 addresses its ENI now holds.
Each protected endpoint now carries its ENI's IPv6 addresses next to the
IPv4 one, and its helper's Docker IPv6 address next to the IPv4
transport. The compiler writes a peer's rules per identity: a rule
matching one of its IPv6 addresses admits it on the IPv6 transport only,
never on the IPv4 one, and on a Docker network without IPv6 there is no
IPv6 identity to match. Every transport a peer has is dropped after its
rules, as the IPv4 one already was. The EC2 and ECS registrations pass
the ENI's IPv6 addresses, the firewall manager reads the helper's Docker
IPv6 address, and AssignIpv6Addresses and UnassignIpv6Addresses update
the ENI's firewall identity. Every Docker address a managed peer has is
dropped after its rules, its IPv6 one included when its ENI holds no
IPv6 address, and an ICMP rule is written only for the family it
belongs to. IPv6 changes to one ENI serialize through their firewall
update; an assign the firewall refuses is taken back out of the store,
and an unassign reaches the firewall before it is stored.
The README now documents enforcement: what it filters, that it needs
rootful Docker with Linux containers, how to turn it on, and that an
application port opened after launch is not published while it is on.
Part of #2564.
A network interface held no IPv6 address: CreateNetworkInterface ignored
Ipv6Addresses and Ipv6AddressCount, AssignIpv6Addresses and
UnassignIpv6Addresses were not implemented, and nothing reported an
ipv6AddressesSet, so a dual-stack subnet's interfaces looked IPv4-only.
CreateNetworkInterface now takes the named addresses or a count drawn
from the subnet's associated IPv6 block, with a random host part. Left
out, the subnet's AssignIpv6AddressOnCreation gives one address; an
explicit 0 overrides it, as the API reference says.
AssignIpv6Addresses reads Ipv6Addresses.N (the name the SDKs send) or
Ipv6AddressCount, needs one of them, and reports only the addresses it
added; UnassignIpv6Addresses reports only the ones the interface held.
Both work on standalone interfaces and on an instance's launch-created
one. An address outside the subnet's blocks answers InvalidParameterValue
and one another interface holds InvalidIPAddress.InUse; prefix
delegation answers UnsupportedOperation, a list with any count
InvalidParameterCombination, and a reserved address (a block's four first
and its last) InvalidParameterValue. An interface holds at most as many
IPv6 addresses as private IPv4 ones, and a block without enough free hosts
answers InsufficientFreeAddressesInSubnet. DescribeNetworkInterfaces and
DescribeInstances report ipv6AddressesSet, and a supplied interface keeps
its addresses on the instance it launches. Termination now releases
interfaces under the topology lock, and an IPv6 change writes back only
what is still stored.
Part of #2564.
ModifyNetworkInterfaceAttribute was not implemented, so a call to change
an interface's security groups, description, source/destination check
or DeleteOnTermination was refused, and with security-group enforcement
on an interface's groups could only change through ModifyInstanceAttribute.
The action now changes a standalone interface or one an instance was
launched with. The group list is read as SecurityGroupId.N, the name the
SDKs and the CLI send. On an instance's primary interface the groups and
the source/destination check are the instance's too. With enforcement
on, a group change reaches the interface's firewall before it is stored,
under the instance's lock, as ModifyInstanceAttribute does, so a policy
that cannot be applied leaves the groups as they were, and the ports the
instance's groups publish are reconciled after a primary-interface change.
The change re-checks the interface and its attachment in the critical
section that stores it, and AttachNetworkInterface and
DetachNetworkInterface now update the standalone record and the instance's
copy under the same topology lock.
ModifyInstanceAttribute no longer overwrites every interface's groups: on
an instance with more than one interface, a group or SourceDestCheck change
answers InvalidInstanceID ("There are multiple interfaces attached to
instance ... Please specify an interface ID for the operation instead."),
the code and message AWS returns, as the Terraform AWS provider quotes them.
The members Floci does not apply (EnablePrimaryIpv6, EnaSrdSpecification,
ConnectionTrackingSpecification, AssociatePublicIpAddress,
AssociatedSubnetIds and the attachment's ENA queue counts) answer
UnsupportedOperation, as ReplaceRoute refuses a target it cannot store,
rather than true with nothing changed.
Part of #2564.
EC2 deleted a terminated instance's root volume through the raw
block-device helper, though a root has no raw backing: it is the
container's own file system. Volume deletion now takes the same root
check that already skips the detach, so termination and reconciliation
remove a root's metadata and tags without calling the helper, while
data volumes keep their backing-storage cleanup. Failed-launch rollback
records the launch's root volume ids before terminating, so a root that
DeleteOnTermination=false kept, or that reconciliation detached first,
is deleted the same way.
Co-authored-by: Andre Kurait <AndreKurait@gmail.com>
EC2 now serves CreateSnapshot, DeleteSnapshot and CopySnapshot for EBS
volumes. CreateSnapshot takes the volume's size and encryption, is owned
by the caller and accepts snapshot tags from TagSpecification.
DeleteSnapshot removes the snapshot and its tags, and refuses with
InvalidSnapshot.InUse while a registered AMI uses it. CopySnapshot copies
from SourceRegion into the request's Region as a new snapshot, encrypted
when the source is, when Encrypted=true or when the destination's
encryption by default says so, without the source's tags. All three
honor DryRun, keeping the error the real call would give.
An unsigned, unversioned CopySnapshot now routes to EC2, since Floci's
ElastiCache does not serve it. RegisterImage builds its snapshot records
through the same helper.
Closes#7943
IMDS answered /latest/meta-data/placement/availability-zone but not
availability-zone-id, which AWS serves and scripts read to pick
zone-specific resources. It now returns the zone's ID, the same one
DescribeSubnets and DescribeAvailabilityZones report for that zone.
RunInstances already refused an AMI whose architecture the instance type
cannot run, as AWS does, but said "The architecture 'x86_64' of the
specified image does not match the architecture supported by instance
type 'm6g.large'.". AWS names the instance type's architecture first:
"The architecture 'arm64' of the specified instance type does not match
the architecture 'x86_64' of the specified AMI."
* fix(ec2): resolve interface identity for tag authorization
* fix(ec2): read resource condition keys through the generated table
* fix(ec2): look up a tag batch's interfaces in one pass
The in-guest IMDS relay listened on 169.254.169.254:80, so Apache and
other wildcard port-80 listeners could not start in an EC2 guest. The
relay now listens on its own port, 42169, and an iptables or nft NAT
rule routes local link-local port-80 traffic to it. The guest's own nft
rules are kept, and only Floci's relay rule is added or removed. With no
working NAT backend, the older port-80 listener keeps IMDS available.
A protected instance's restart retires a retained older listener before
the workload starts, and a failed start rolls back the IMDS registration
it made. The network helper image now includes iptables.
Closes#7937
EC2 network operations with resource-scoped policies were checked against
`*`, and stored ownership conditions were missing. Every EC2 request is
now read by the generated request-resource rules, its EC2 Query list
names from botocore, so a resource-scoped policy applies to each EC2
operation whose request names a resource. A list a type's ARN variable
names is the request's targets only when the request names nothing
else, and the sg-, acl-, rtb- and eni- id prefixes come from botocore's
examples.
Each target is evaluated with its own stored tags, under every EC2
type's Service Reference resource-tag keys, and tags on creation are
authorized separately. A forged SDK spelling cannot replace an EC2 wire
value. ENI creation tags are kept in the regional tag index and stay in
sync with CreateTags and DeleteTags.
Closes#8286Closes#8287Closes#8291Closes#8295Closes#8300Closes#8306
Authorize generated instance targets with their own stored tags before mutation. Return malformed Query errors as XML HTTP 404, reuse enforcement group cleanup, and update generated-target regression coverage. Regenerate IAM metadata on current main.
Closes#8159
* fix(ec2): preserve security group deletion scope and dependencies
Coordinate group publication, attachment and deletion, preserve instance/interface group state, and reject invalid DryRun values before deletion.
Signed-off-by: Andre Kurait <akurait@amazon.com>
* fix(ec2): tolerate absent persisted group dependency fields
Keep unknown-state instance attachments blocking deletion while treating absent dependency collections as empty. Cover all nullable scan fields and missing identifiers without changing normal dependency semantics.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(ec2): roll back failed security group creation
Retain the default rule identity before publication and compensate both group and rule writes when either store fails. Preserve the original exception and record cleanup failures without skipping the remaining cleanup.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(ec2): serialize group rule references with deletion
Acquire the regional topology monitor before the source group monitor while resolving and publishing ingress and egress rules. Keep runtime reconciliation outside the mutation locks and preserve existing unknown-reference compatibility.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(ec2): retain groups used by Instance Connect endpoints
Reject deletion before mutation when an Instance Connect endpoint uses the group. Return CannotDelete for default groups and reuse shared SDK clients in the existing fixtures.
Signed-off-by: Andre Kurait <akurait@amazon.com>
* refactor(ec2): share resource locks and deletion race helpers
Reuse the reference-counted lock lifecycle for volume operations and instance group assignments. Keep scoped keys and lock ordering unchanged. Reuse deletion tasks and blocked-or-done observations without weakening race assertions.
Signed-off-by: Andre Kurait <akurait@amazon.com>
---------
Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Systemd guests ran with --cgroupns=host and the host's /sys/fs/cgroup bound
in, so every guest's systemd managed the same cgroup tree as the Docker
host and as each other. Two guests running Kubernetes nodes (kubelet with
the systemd cgroup driver, as Kubernetes The Hard Way configures it)
shared one kubepods.slice: both nodes saw the same inode, and each kubelet
tore down the other's pod sandboxes, so every pod restarted in a loop
(SandboxChanged, "network namespace for sandbox ... is closed").
A private namespace without the bind, as kind runs its nodes, gives each
guest's systemd its own writable subtree, because Docker mounts it
read-write for a privileged container. Measured on OrbStack (cgroup v2):
two guests boot to 'running', each with cgroup 0::/init.scope on a
distinct cgroupfs root.
A guest under security-group enforcement runs unprivileged, and Docker
mounts an unprivileged container's private cgroupfs read-only, where
systemd cannot create its slices. That guest keeps the host namespace and
the read-write bind, so it boots as before; the docs say its cgroups stay
shared.
fix(ec2): keep the IMDS proxy out of a systemd guest's root cgroup
A privileged systemd guest now has a private cgroup namespace, and a
docker exec lands in that namespace's root. Floci leaves its link-local
IMDS proxy (socat) running from such an exec, so the guest's root cgroup
held a process. cgroup v2 will not enable controllers in a cgroup's
subtree_control while it holds processes, so the root's stayed empty and
kubelet with the cgroupfs driver died creating kubepods.slice
("openat2 /sys/fs/cgroup/kubepods.slice/pids.max: no such file or
directory"). Whether a node hit it depended on whether anything else
enabled the controllers before the proxy started.
The proxy's install and start scripts now move their own shell into the
leaf /sys/fs/cgroup/floci first, so socat and everything else they start
stay out of the root. They do so only at the root of a cgroup v2
namespace whose cgroupfs is writable; a host-namespace container, a
cgroup v1 host and a read-only mount run as before. A plain directory
rather than systemd-run, because the proxy starts while the guest's
systemd may still be booting, and systemd neither reaps nor moves a
cgroup it did not create. EKS's pod-identity proxy shares the script.
The Docker integration test launches a privileged systemd guest through the real
container spec. It now also reads /proc/self/cgroup, which must be 0::/ at the
namespace root, and creates and removes a directory under /sys/fs/cgroup, so
native Linux CI fails if the guest falls back to the host cgroup namespace.
Rewrap the class javadoc, rename the test to cover both the modules and the
cgroup namespace, and comment what each cgroup probe does and does not prove.
Preserve default versions and the highest issued version across deletion, persistence and CloudFormation rollback.
Reject invalid DryRun values before deletion, tolerate only already-deleted versions during CloudFormation rollback, and preserve the resolution race fixture without reflective field mutation.
Reuse presence checks to retain name-specific disappearance errors and existing service-test factories.
Reuse existing EC2 test factories and the shared blocked-or-done wait while preserving all race assertions.
Signed-off-by: Andre Kurait <akurait@amazon.com>
Use the existing VPC-specific default-group lookup for instance launch, with
service and SDK placement regressions and documentation.
Source: AndreKurait/floci#524 (94f76eae34e46dc1e740b6349bbaed578a15e372).
Remove the obsolete regional resolver and its dedicated test assertions now
that instance launch uses the VPC-specific lookup. Keep legacy VPC resolution
coverage and remove its unused security-group fixture.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
Co-authored-by: Andre Kurait <AndreKurait@gmail.com>
A systemd guest shares the Docker host's kernel but ships none of its
modules, so `modprobe br_netfilter` (Kubernetes node setup, e.g. Kubernetes
The Hard Way lab 9) fails with "Module not found in directory
/lib/modules/<kver>" even when the module is built in. kind binds the
host's tree the same way. Docker creates a missing bind source as an empty
directory, so hosts without /lib/modules still launch.
Privileged systemd guests can now load any module in that tree into the
shared host (or Docker Desktop / OrbStack VM) kernel, so docs/services/ec2.md
carries a warning saying so.
test(ec2): prove a systemd guest gets /lib/modules read-only on a real daemon
Ec2SystemdGuestDockerIntegrationTest launches through the real
Ec2ContainerManager container spec against Docker, with an Alpine image
standing in for a systemd cloud image (its busybox /sbin/init stays up as
PID 1), and checks the mount both from the daemon's inspect and from the
guest's /proc/mounts. It is skipped when Docker is unavailable.
docs/services/ec2.md now says that on Docker Desktop or OrbStack the tree
is the VM's and may not match its running kernel, and states exactly when
an instance runs privileged: only with security-group enforcement off. With
enforcement on, the guest joins the protected namespace unprivileged, and a
namespace that cannot be created fails the launch.
docs(ec2): say the read-only modules mount does not bind a privileged guest; keep test cleanup from masking failures
The read-only bind keeps an unprivileged guest from changing the tree, but a
privileged guest can remount it read-write, so the first paragraph no longer
claims the guest cannot load a module the host kernel lacks.
The systemd guest test now logs a failed container removal instead of
throwing it over the assertion error it is reporting.
fix(ec2): bind only the running kernel's /lib/modules dir into systemd guests; tear down the integration test via terminate()
test(ec2): pin that the guest's /lib/modules outside the bound kernel dir stays writable; document missing-dir and linux-modules caveats
An AWS::EC2::Instance that names a launch template took the template's
image, type, key and metadata options but never its IamInstanceProfile,
so describe-instances showed no profile. When the instance declares no
profile of its own, it now launches with the template's, resolved the
same way RunInstances resolves it. The instance's own profile still wins.
A stack update that moves the instance to a template version naming
another profile, or none, changes or removes the profile in place, and a
dropped LaunchTemplate removes the profile it supplied. A rollback of an
update that changed the profile, whether the instance or its template
declared it, now puts the previous profile back instead of ending
UPDATE_ROLLBACK_FAILED.
Part of #7603
Move the Java sources from io.github.hectorvent.floci to io.floci.aws, matching io.floci.gcp, io.floci.az and io.floci.oci. Generated by tools/rename/rename_package.py apply on the base commit, with no other edits.
Logger categories and the arn.fail-on-blank-region property move to the io.floci.aws prefix. The pom groupId becomes io.floci; the artifactId stays floci.
Refs #6589
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
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.
Populate existing instance types with AWS-verified manufacturer values and expose them through DescribeInstanceTypes. Add SDK regression coverage for all 84 catalog entries.
Closesfloci-io/floci#7516
* 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>
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.
Closesfloci-io/floci#7500
* 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.
* 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
* 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
* 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
* 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.
Closesfloci-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.
* 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>
* 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>
* 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>