feat(lambdaweb): keep the code a revision was created from (#6113)

* feat(lambdaweb): keep the code a revision was created from

A revision reads its code object at creation and keeps its own copy under
the Lambda code path. New environments start from that copy, so a later
write or delete in the bucket no longer changes what the revision runs.
AWS pins the version that was current at creation when the request names
none, and serves it after that version is deleted.

A versionId that cannot be read gets the AWS wording. A 404 from S3 says
the object does not exist with the versionId, and any other error says the
object is inaccessible.

* fix(lambdaweb): start environments only from the kept code

Lambda Web is in no release yet, so every stored revision has its copy and
the S3 fallback could only run changed code. A missing copy is now an error.

At start the copies that no stored revision names are removed, such as
those a restart in memory mode or a failed delete left behind. A failed
write removes its partial file. Path segments escape every byte but
letters, digits, - and _, so two region names never share a directory.

* fix(lambdaweb): stream the code copy instead of holding it in memory

A revision now streams its code object from S3 into its copy, and an environment opens that copy in place through a new ZipExtractor overload. Neither step loads the object into the heap, and a start no longer writes the archive to disk again before unpacking it.

* chore: share one recursive delete across services

FileTrees.delete replaces the copies in Lambda Web, ZipExtractor, CodeStore, Lambda layers, CodeBuild, S3 and CodeArtifact. Each caller keeps its own log message and level. A failure no longer stops the rest of the tree, and the walk stream is always closed.
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-10-21 00:51:57 -04:00
1 parent 03836d5244
commit bf82846971
15 files changed
+439 -106

No files matched your search

+2 -1
View File
@@ -35,7 +35,8 @@ The `Lambda Web` service model (apiVersion 2025-03-07, `aws lambda-web` in the A
## Emulation Behavior
- **Instant convergence:** a revision and an endpoint are stored `Active` and an endpoint update is stored `Successful`. The create and update responses still report the transitional state AWS reports (`Pending`, `updateStatus: InProgress`, and the per-region block as it was before the update), so a waiter sees one poll.
- **Code comes from S3 only.** The object named in `buildConfig.codeConfig.s3Object` must exist in Floci's S3, as on AWS. AWS also requires bucket versioning and a bucket policy for the Lambda service principal. Floci does not check them yet, and the revision does not pin a `versionId` the request did not give yet.
- **Code comes from S3 only.** The object named in `buildConfig.codeConfig.s3Object` must exist in Floci's S3, as on AWS. AWS also requires bucket versioning and a bucket policy for the Lambda service principal. Floci does not check them yet.
- **Each revision keeps its own copy of the code**, read at creation from the version the request names or the current one, under the Lambda `code-path`. As on AWS, a later write or delete in the bucket does not change what the revision runs. AWS moves a revision to `Failed` when it later finds its object version gone, which Floci does not do.
- **Execution role and network connector** ARNs are checked for shape only. The assume-role check AWS makes is not done yet.
- **Resource policies** are checked the way AWS checks them before storing: the document grammar, a `lambda:` action, a `Resource` that names the function, a valid principal, and no public `Allow`. A wildcard principal needs a positive condition (`StringEquals`, `StringLike`, `ArnLike`, `Bool`) on a trusted key such as `aws:PrincipalAccount` or `aws:PrincipalArn`, with no wildcard in the account it names. An `IamAuth` endpoint evaluates it on requests, as below.
- **ARNs** given as identifiers must name the request's region and the caller's account, as on AWS. A revision or endpoint ARN resolves by its id or name only.