Commit Graph
3 Commits
Author SHA1 Message Date
TATSUNO “Taz” Yasuhiro 62972c91bf feat(lambdaweb): fail a revision whose code is not a zip (#6141)
* feat(lambdaweb): fail a revision whose code is not a zip

A revision whose code is not a zip is Failed, as on AWS, and cannot be
deployed. The endpoint CreateWebFunction makes on such a revision is
Failed too and answers 409 Platform.EndpointNotActive. An empty object
is a 500 InternalServerException with an empty body, as on AWS.

* fix(lambdaweb): remove a code copy that cannot be read and name the {} body

* test(lambdaweb): upload a real zip in the compatibility tests
2026-10-21 22:56:15 -04:00
TATSUNO “Taz” Yasuhiro 6e01216f88 feat(lambdaweb): serve endpoint domains from a Node.js environment per revision (#5760)
* feat(lambdaweb): serve endpoint domains from a Node.js environment per revision

A request whose Host is an endpoint's domainName goes over HTTP/1.1 to
a container that Floci starts from the revision's S3 code on the first
request: public.ecr.aws/lambda/nodejs:24 with the code in /var/task,
index.js or AWS_LAMBDA_NODEJS_ENTRYPOINT as the entry file, the node
flags and the environment variables AWS sets, ten seconds to listen,
SIGTERM and one second when idle, and a fresh environment after the
process exits between requests.

The forwarded request carries the headers AWS adds and loses the ones
AWS drops. The response carries lambda-web-request-id and
lambda-web-logstream and streams as the app writes it. Two revisions in
revisionWeights split the traffic by weight. The platform pages for an
unsupported method, an unknown domain, HTTP/1.0, a server that does not
listen, a timeout, a crash and a disabled endpoint are the AWS pages.

Part of #5699

* fix(lambdaweb): index endpoint domains and claim only the minted host shapes

A request looked its domain up by scanning every stored function across
accounts and iterating live endpoint maps outside the function lock. The
service now keeps a domain index, filled from storage at start and kept
by the create and delete paths, and copies the function under its lock.
The data plane claims only hosts shaped like the domains Floci mints, in
any case and with any port, so a dotted S3 bucket with a lambda-web
label still reaches S3.

* fix(lambdaweb): reserve environments against the idle reaper and track exits

acquire now reserves the environment under the same lock the idle
reaper takes, so a request cannot start on a container the reaper is
about to stop. Docker faults in the reaper and in discard are contained
so one error does not end the periodic run or skip the removal. The exit
watcher records the exit time and arms itself again when its stream
drops, and a request that found a dead process is replayed only when
that recorded exit came first, never because the container is gone. The
unpacked code directory is removed on every path. The container gets the
execution role's session credentials when the role exists, and the
function account's credentials otherwise, as the Lambda launcher does.

* fix(lambdaweb): bound the whole exchange by timeoutSeconds and forward chunked bodies

timeoutSeconds is a deadline on the whole request, as recorded against
AWS: a response that has not started by then is the 504 page, one that
is still streaming is cut, and a slow upload gets its 504 once the body
is in, since the edge takes the body before it answers. A body without a
Content-Length is sent chunked instead of carrying the client's
Transfer-Encoding header. A failure of the upload stream ends the
exchange and releases the environment once.

* test(compat): probe the unknown Lambda Web domain in the shape Floci mints

The data plane claims only hosts shaped like the domains it mints, so
the unknown-domain check needs a 16 character id to reach it.
2026-10-15 22:50:05 -05:00
TATSUNO “Taz” Yasuhiro 6f78083080 feat(lambdaweb): Lambda Web Functions control plane (#5706)
* feat(lambdaweb): Lambda Web Functions control plane

The lambda-web service model (apiVersion 2025-03-07) signs as lambda, so
it is served under the lambda service at /2025-03-07/... with the AWS
wire shapes, state words and error wording of the 20 operations on web
functions, revisions, endpoints, tags and the resource policy.

Revisions and endpoints converge at once. They are stored Active and an
endpoint update is stored Successful, while the create and update
responses report the transitional state AWS reports, so a CLI waiter
settles on its first poll. Code comes from an S3 object that must exist.
IamAuth, the resource policy and the endpoint domain are stored but not
served yet.

Part of #5699

* fix(lambdaweb): carry the page position in the token

The nextToken of a list operation was a UUID keyed into an in-memory
anchor map that only grew and was not scoped to the account. The token
is now a core Pagination cursor that encodes the request (operation,
region, account, function, filters and page size) and the cursor of the
item the page ended on. A token reused with other parameters gets the
AWS "does not match the request" error and any other token the AWS
"invalid or has expired" error.

AWS issues UUID tokens and rejects any other shape, so Floci no longer
reproduces the pattern error for a malformed token.

* fix(iam): resolve a Lambda Web revision or endpoint named by its ARN

The route resource for IAM enforcement took the path segment after
revisions or endpoints as the id. A revision or endpoint ARN in that
position carries slashes, so the resource ARN ended in the ARN's first
segment and a policy scoped to the revision or endpoint did not apply.
The id is now the last segment of such an ARN.

* fix(lambdaweb): add the values of a repeated state filter

AWS lists a function when any state filter in the request names its
state. A later state filter replaced the earlier one, so a request with
state=Active followed by state=Failed listed nothing.

* fix(lambdaweb): refuse empty arrays in a resource policy

AWS answers an empty Action or Resource array with the policy syntax
error and an empty principal array with the invalid principal error,
which wins when all three are empty. Floci stored such a policy.

* fix(lambdaweb): judge a wildcard principal by the operator and value of its condition

A trusted condition key alone kept an Allow for every principal out of
the public check. AWS blocks the policy unless a positive operator pins
the key: StringNotEquals and the IfExists forms do not count, nor does a
wildcard in an account value or in the account field of an ARN value,
while a wildcard elsewhere in an ARN and a literal * under StringEquals
do.
2026-10-15 06:46:52 -04:00