Repository navigation
feat(cloud): host the fleet gateway on AWS Lambda - #301
Merged
Merged
Conversation
outofcoffee
force-pushed
the
feat/lambda-gateway-hosting
branch
from
November 28, 2026 23:03
e7fa15b to
9638651
Compare
Adds `spinloop cloud gateway deploy/destroy`: deploy stages the function ZIP (the gateway binary, the fleet file and every Spinloop source the file names, under /var/task/config/), drives the gateway stack's deploy through the same version-matched-sources machinery as bootstrap, and prints the Function URL; destroy removes the stack and nothing else. The gateway serves the same handler in Lambda mode (SPINLOOP_LAMBDA=1, the fleet file baked at /var/task/config/fleet.yaml) behind a Function URL with the gateway's own bearer token as the only caller gate — no secret in the ZIP, the caller token set on the function at deploy time.
…tack The gateway stack imports StartFnArn, StatsFnArn and StackArn from the control-plane stack via Fn::ImportValue, but the outputs carried no export name — CloudFormation refuses the import and the gateway stack rolls back at creation. Export all three with the names the gateway imports, and assert the exports in the stack test.
…missing the ARN outputs The gateway stack imports StartFnArn, StatsFnArn and StackArn from the control-plane stack; a plane deployed before this change exports none of them, so the stack failed creation and rolled back at the cdk step. Read the control plane's outputs before building the ZIP and fail with the fix named — re-run spinloop cloud bootstrap — instead.
update-function-configuration replaces the whole Variables map, so the documented command would have wiped SPINLOOP_LAMBDA and SPINLOOP_API_TOKEN along with the token it added. Document the replace semantics, show the merged map, and name how to find the function.
…mmand The Lambda runtime invokes the binary with no arguments and no command name, so the gateway subcommand never ran and the binary printed the help text and exited non-zero in init. Detect SPINLOOP_LAMBDA=1 in run(), before the command tree is built, and dispatch to the Lambda gateway. Adds a test asserting the dispatch returns the handler's error rather than the help text.
outofcoffee
force-pushed
the
feat/lambda-gateway-hosting
branch
from
November 29, 2026 00:20
57e2c40 to
174f0d0
Compare
The gateway's function runs VPC-attached to the control plane's own VPC (public subnets, the same shape the engines launch into) with its own security group — outbound only — recorded in the well-known SSM parameter /cloud-vm-llm/gateway/security-group-id. The environment deploy's ingress reconciliation admits the gateway's security group alongside the deploying machine's CIDR, so the gateway reaches every deployed cloud node regardless of whether the node has an SG entry for the deploying machine. The engines' ingress is never widened to 0.0.0.0/0.
AWS rejects non-ASCII characters in a security group description; the em dash in the gateway's description failed the stack deploy.
IpPermission has no SourceSecurityGroupId field — the SDK silently dropped it, so the reconcile authorized a sourceless rule and the SG kept only the CIDR. Both sources now ride in one rule, the shape AWS produces.
…-plane VPC The Lambda hosting subcommands move from `cloud gateway` to `spinloop gateway` (deploy, show, destroy): the gateway is a serving mode of the foreground command, so its hosting lives under the same name. The deploy now passes the control plane's private subnets and the stated plane URLs to the stack; show prints the deployed gateway's URL and diagnostics, read live. The gateway's function runs in the control plane's private subnets routed through the NAT gateway and reaches engines at their VPC-private IP, so the start Lambda reports the instance's private_ip and the gateway swaps to the private address on the engines' own network.
Sync the delta spec into the new main spec openspec/specs/lambda-gateway-hosting/spec.md (purpose plus eight requirements, every scenario intact) and archive the change under openspec/changes/archive/2026-11-30-lambda-gateway-hosting/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serve the fleet gateway on AWS Lambda behind a Lambda Function URL — the same handler, the same paths and the same bearer-token gate as the foreground gateway, with no long-lived host.
Summary
spinloop cloud gateway deploystages the function ZIP (the gateway binary, the fleet file and every Spinloop source the file names, baked under/var/task/config/), drives the gateway stack's deploy through the same version-matched-sources machinery asbootstrap, and prints the Function URL to name in the fleet file'sgatewaysection.spinloop cloud gateway destroyremoves the gateway stack and nothing else; it is a no-op when the stack is absent.SPINLOOP_LAMBDA=1) and serves the handler through the AWS Lambda adapter — the sameinternal/gateway, no forked logic. The fleet file defaults to/var/task/config/fleet.yaml(orSPINLOOP_FLEET_PATH).cloud-vm-llm-gateway) is a custom-runtime Lambda (ARM_64, 900 s) behind a Function URL (RESPONSE_STREAM, auth NONE — the gateway's own bearer token is the only caller gate), with a role scoped to the control-plane start and stats functions plus stack discovery, and a bounded-retention log group.--api-tokenorSPINLOOP_API_TOKEN), the fleet file baked in names environment variables, and every node/engine token resolves from the function's environment at invocation time.Closes #298
Implementation details
bootstrapas the fix.file:field or a subdirectory beside the fleet file).spinloop_linux_arm64.tar.gzfrom the matching GitHub release), or ago buildfrom the source tree for a dev build.