Commit Graph
36 Commits
Author SHA1 Message Date
TATSUNO “Taz” Yasuhiro c4ae11c414 feat(cloudformation): expose RegionalEndpoints of a web function endpoint to Fn::GetAtt (#6907) 2026-10-29 08:25:24 -04:00
TATSUNO “Taz” Yasuhiro a682400d45 fix(lambdaweb): check the endpoint quota after the revisions an endpoint routes to (#6888)
Lambda refuses a missing or Failed revision, a Failed latest revision and
a connector revision on a PerRegion or MultiRegion endpoint before it
refuses an endpoint past the maxEndpointsPerFunction quota.
2026-10-28 22:35:14 -04:00
TATSUNO “Taz” Yasuhiro 177f8e9360 fix(lambdaweb): accept a policy Action of "*" or any case of lambda (#6883)
Lambda takes "*" or "<service>:<action>" with a service of letters,
digits, dots and dashes. Each action names lambda in any case, unless the
list also holds "*", which lets actions of other services through.
2026-10-28 21:07:10 -04:00
TATSUNO “Taz” Yasuhiro 9217533e76 fix(lambdaweb): give the container the memory the process sees on AWS (#6869) 2026-10-28 20:15:38 -04:00
TATSUNO “Taz” Yasuhiro fc1388da6f fix(lambdaweb): accept a policy Resource in any partition, region or account (#6863) 2026-10-28 20:04:40 -04:00
TATSUNO “Taz” Yasuhiro c55cb887d5 fix(lambdaweb): check resource policy statements in the order AWS does (#6788)
AWS runs each policy check on every statement before the next check. It answers an Effect other than Allow or Deny with "Invalid effect: <value>", and a malformed Principal or a non-string Effect with "Syntax error at position (-1,-1)".
2026-10-28 09:22:20 -04:00
TATSUNO “Taz” Yasuhiro 0c549d267b fix(lambdaweb): refuse an Allow for a federated principal as public (#6789)
AWS blocks an Allow whose principal is Federated unless its values include "*" or a trusted condition pins the caller. It checks no pattern on Federated or CanonicalUser values.
2026-10-28 06:54:08 -04:00
TATSUNO “Taz” Yasuhiro 701b04c410 feat(lambdaweb): reject resource policies whose principal does not exist (#6769)
* feat(lambdaweb): reject resource policies whose principal does not exist

PutResourcePolicy now looks up every AWS principal a policy names, as Lambda
does before it stores the policy. A role or user ARN has to name one IAM
holds in that account, under its own path, and a unique id one in the
function's account. A missing principal, an assumed-role session, a
CanonicalUser or an ARN in another partition gets the invalid principal
message, and a role or user named under another path gets the message
that the ARN does not match the actual one.

The principals are looked up after every statement passes its other
checks and before any statement is refused as public, which is the order
AWS checks them in.

* docs(lambdaweb): drop the principal check from the items not implemented yet

* refactor(lambdaweb): find policy principals through IamService and the resolver's partition

IamService.heldPrincipalArn now gives the ARN IAM holds what a principal
ARN names under, the root as given or the role or user at its own path.
DSQL's principal check and Lambda Web's use it, and Lambda Web keeps only
the path comparison and its messages. Lambda Web takes the partition from
RegionResolver.partitionForRegion, so a custom region falls back to the
deployment's partition.
2026-10-27 22:00:28 -04:00
TATSUNO “Taz” Yasuhiro b0cd70401b feat(iam): check lambda:PassNetworkConnector from a table generated from the Service Reference (#6699)
* feat(lambdaweb): check lambda:PassNetworkConnector as AWS does

A revision that sets egressNetworkConnectorArn needs
lambda:PassNetworkConnector on the connector version ARN as given.
Lambda checks it after the connector ARN checks and before it looks
the connector up.

A refusal names the first policy type that refuses, in the order
identity policies, permissions boundary, session policy. An explicit
deny in a managed policy or a boundary also names that policy's ARN.

* fix(lambdaweb): apply service control policies to the account root when passing a connector

* fix(lambdaweb): name the managed policy that denies a session token caller

* feat(iam): check lambda:PassNetworkConnector from a generated table

Move the check out of Lambda Web into the IAM enforcement filter, where
iam:PassRole is checked. tools/aws/regen_iam_passed_network_connectors.py
joins AWS's Service Reference and botocore's models into
src/main/resources/aws/iam-passed-network-connectors.json, and the filter
reads it for Web Functions, MicroVM images and MicroVMs.

A MicroVM request that names no egress connector, or an empty list, passes
the Lambda-managed INTERNET_EGRESS connector, and RunMicrovm with no ingress
connector passes HTTP_INGRESS, as AWS checks them. AppSync's data source
operations are listed too, but botocore's model has no member for their
connector, so they are not read.

The refusal text now comes from AccessDeniedMessages, which
LambdaTaskAuthorizer and GetStackOutputRoleAuthorizer use as well.
2026-10-26 23:26:25 -04:00
TATSUNO “Taz” Yasuhiro ec13eda221 feat(lambdaweb): check the egress network connector as AWS does (#6647) 2026-10-26 10:51:01 -04:00
TATSUNO “Taz” Yasuhiro c7b3d04e5b fix(lambdaweb): do not clean up the revision a LatestRevision endpoint leaves (#6565)
AWS deletes it only when the next revision turns Active.
2026-10-25 21:23:21 -04:00
TATSUNO “Taz” Yasuhiro 29eae434f6 feat(lambdaweb): delete the oldest unused revisions past 50 as AWS does (#6518)
* feat(lambdaweb): delete the oldest unused revisions past 50 as AWS does

When a revision turns Active and the function has more than 50, AWS
deletes the oldest revisions no endpoint routes to until 50 are left.
Failed revisions count and go too. A new Failed revision deletes nothing.

* docs(lambdaweb): place the revision cleanup note after the code copy note
2026-10-25 10:12:15 -04:00
TATSUNO “Taz” Yasuhiro 8f3a6eafeb fix(lambdaweb): give the code bucket check the version as s3:VersionId (#6483) 2026-10-25 07:39:20 -04:00
TATSUNO “Taz” Yasuhiro cd2dac708d feat(lambdaweb): check the code bucket versioning and policy as AWS does (#6479) 2026-10-24 23:33:50 -04:00
TATSUNO “Taz” Yasuhiro acb9fd2cd6 feat(lambdaweb): serve the MultiRegion global domain in the default region (#6460)
* feat(lambdaweb): serve the MultiRegion global domain in the default region

AWS serves the global domain from the region nearest the caller. Floci
now takes floci.default-region for where the caller is. The global domain
is served in that region when the endpoint lists it, and in the home
region otherwise. The environment, logs, metrics, SigV4 and
aws:RequestedRegion then use that region, as on AWS.

* fix(lambdaweb): use the serving region as aws:RequestedRegion for CloudFront

A CloudFront origin request got the home region from the endpoint ARN.
On AWS it is the region that serves the request, for the global domain
and for a regional domain alike.
2026-10-24 21:06:25 -04:00
TATSUNO “Taz” Yasuhiro 72bbc809b4 feat(lambdaweb): serve each region of a PerRegion endpoint in that region (#6423)
* feat(lambdaweb): serve each region of a PerRegion endpoint in that region

A request to the regional domain of another region now runs in an
environment of that region. It gets that region in AWS_REGION and from
the metadata endpoint, and maxEnvironments and rateLimit count per region.
Its .local logs and its metrics go to that region. The centralized logs
and AWS/Lambda/Web also go to the home region, as on AWS. SigV4 and
aws:RequestedRegion use the region of the domain. The regional domains
share one id, as on AWS. The MultiRegion global domain stays in the home
region.

* test(lambdaweb): wait for the logs once and cover the mirror region deny

The Docker test now waits only for the centralized stream, since each
batch reaches the .local group first. The Authorization headers come from
EnforcementFixtures.auth. The RequestedRegion test also denies us-east-1
and checks that the west domain is still allowed.
2026-10-24 18:23:19 -04:00
TATSUNO “Taz” Yasuhiro 4e0bf080ed fix(lambdaweb): refuse a function name another region already has (#6409)
* fix(lambdaweb): refuse a function name another region already has

AWS keeps web function names unique across the regions of an account.
CreateWebFunction with a name another region has is 409
ConflictException "A function named <name> already exists in the
account. Function names must be unique across all regions in an
account.", at the same point as the same-region conflict.

* fix(lambdaweb): key the function name lock by account

* perf(lambdaweb): find a name in other regions without copying every key
2026-10-24 08:37:19 -04:00
TATSUNO “Taz” Yasuhiro 54b3db771a feat(lambdaweb): serve the Lambda metadata endpoint (#6391)
* feat(lambdaweb): serve the Lambda metadata endpoint

AWS gives each environment AWS_LAMBDA_METADATA_API, AWS_LAMBDA_METADATA_TOKEN
and AWS_LAMBDA_RUNTIME_API, all at one server. It answers the zone id to a
Bearer token with any method, "Client.Unauthorized" with 401 to anything
else, Go's 404 to another path before the token, and a 307 to the clean
path.

* fix(lambdaweb): take the metadata port outside the Runtime API range

The width of that range is the Lambda concurrency, and its ports are only
reached over the Docker network, as any other port is. A listen that fails
now closes its server.

* fix(lambdaweb): start the metadata server before a start mints a session

A metadata server that could not start left the role session and the token
of an environment that never ran.
2026-10-23 23:05:55 -04:00
TATSUNO “Taz” Yasuhiro 7e6439cf86 feat(lambdaweb): check the execution role as AWS does (#6347)
* feat(lambdaweb): check the execution role as AWS does

AWS refuses a revision whose execution role is in another account with
403 AccessDeniedException. It refuses a role that does not exist or does
not trust lambda.amazonaws.com with 400 ValidationException, and that
check gives no aws:SourceAccount or aws:SourceArn. An environment
assumes the role with the function as its source, and a request gets
502 Platform.CannotAssumeRole when Lambda can no longer assume it.

* fix(iam): match a wildcard principal and the service keys in service trust

{"AWS": "*"} lets Lambda assume a role, and a Deny on it refuses the role.
Lambda sets aws:PrincipalIsAWSService to true and aws:PrincipalServiceName
to its principal when it checks the role and when an environment assumes it.

* fix(lambdaweb): answer CannotAssumeRole when the role goes during a start

A role deleted after the trust check gave the container the account's
placeholder credentials. AWS answers 502 Platform.CannotAssumeRole for a
deleted role.
2026-10-23 10:50:14 -04:00
TATSUNO “Taz” Yasuhiro e7ca14b03b fix(lambdaweb): apply a revision's NODE_OPTIONS as AWS does (#6290)
* fix(lambdaweb): let heap flags in NODE_OPTIONS replace the defaults as AWS does

AWS drops both of its heap flags when NODE_OPTIONS names
--max-old-space-size or --max-semi-space-size, and puts those on the
command line in their place. Floci kept its own flags, so a larger heap
set in NODE_OPTIONS lost to --max-old-space-size=1024.

* test(lambdaweb): copy a quoted heap value from NODE_OPTIONS as AWS does

AWS puts --max-old-space-size="1536" on the node command line with its
quotes. Node refuses that value, so the start fails with
Runtime.ExitError.

* docs(lambdaweb): put the NODE_OPTIONS sentences after the require.main one

* test(lambdaweb): share the default heap flags in the NODE_OPTIONS tests
2026-10-23 06:43:27 -04:00
TATSUNO “Taz” Yasuhiro 2720f84884 feat(lambdaweb): accept code up to 512 MiB and refuse more as AWS does (#6218)
* feat(lambdaweb): accept code up to 512 MiB and refuse more as AWS does

AWS takes a Web Function package of up to 536870912 bytes, zipped and
unzipped. A larger object is a 400 ValidationException at creation. A zip
whose files add up to more gives a Failed revision.

* fix(lambdaweb): add the declared sizes as unsigned numbers like AWS

AWS adds the sizes as unsigned 64-bit numbers and stops at the largest
one. A zip that declares sizes past the signed range is Failed too.

* test(lambdaweb): declare the large sizes instead of writing them
2026-10-22 10:40:03 -04:00
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 bf82846971 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.
2026-10-21 00:51:57 -04:00
TATSUNO “Taz” Yasuhiro 5aaa37284c feat(lambdaweb): refuse a long request head as AWS does (#6083)
A head past 128 KiB gets the AWS edge page 431 Platform.HeaderTooLarge before every other check. A URI of 65,535 bytes or more gets an empty 414.

The HTTP server now reads heads up to 256 KiB so the data plane can answer them. Every other host keeps the Quarkus defaults of 4096 bytes for the request line and 20 KiB for the headers.
2026-10-20 13:12:33 -04:00
TATSUNO “Taz” Yasuhiro 8bff1ba0f3 feat(cloudfront): sign requests to a Lambda Web Function origin under OAC (#6037)
* feat(cloudfront): sign requests to a Lambda Web Function origin under OAC

CreateOriginAccessControl now takes always-amz-auth for the lambda origin
type and sigv4a for s3 and lambda, with the AWS validation messages.
Distributions check the origin access control of a Lambda origin as AWS
does, and refuse a Lambda@Edge origin trigger in front of an origin signed
with always-amz-auth or sigv4a.

Under always-amz-auth, CloudFront signs its requests to a Web Function
endpoint of this Floci for the distribution. An IamAuth endpoint lets them
through, or under IAM enforcement evaluates the function policy for
cloudfront.amazonaws.com with aws:SourceArn and aws:SourceAccount.

* fix(cloudfront): refuse unknown and in-use OAC changes as AWS does

A distribution naming an origin access control that does not exist is
InvalidOriginAccessControl. A control an origin uses can no longer change
its origin type, its signing protocol, or whether it is always-amz-auth,
which AWS answers with IllegalUpdate.

* fix(cloudfront): match a Lambda origin by the end of its hostname

CloudFront takes a Lambda origin only from a hostname under on.aws, and it matches the fixed labels case sensitively. Floci also takes one under its own host.

The CloudFront check and the caller check now share the endpoint condition keys. The docs say when CloudFront forwards the viewer Authorization.

* fix(cloudfront): read the Floci host for Lambda origins from the authority

URI.getHost is null for a host with an underscore, such as a Compose service name, which broke CloudFront at startup. The Web Function endpoints are named from the authority, so the match reads it the same way.
2026-10-20 08:26:11 -04:00
TATSUNO “Taz” Yasuhiro 7fb649715c fix(cloudfront): serve a Lambda Web Function endpoint origin from Floci itself (#6022)
* fix(cloudfront): serve a Lambda Web Function endpoint origin from Floci itself

A custom origin whose domain is an endpoint this Floci minted now goes to
the listener the viewer reached, with the endpoint domain as Host. Before,
the endpoint host did not resolve, and loopback failed the private address
check.

As on AWS, a forwarded viewer Host is a 502, because the endpoint's
certificate does not name it.

* fix(cloudfront): fetch the endpoint origin over plain HTTP for TLS viewers

A viewer over TLS reached the HTTPS port, and Floci sent plain HTTP to it.
The request now goes to the plain HTTP port at the same address.

The endpoint domains are also indexed by the host a CloudFront origin
names, so a base URL host with upper case or a trailing dot still matches.
2026-10-19 21:06:57 -04:00
TATSUNO “Taz” Yasuhiro 6e5b1569fe feat(lambdaweb): publish the Web Function metrics (#5976)
* feat(lambdaweb): publish the Web Function metrics to CloudWatch

AWS counts a request that reached an environment in ExecutedRequests, also one answered with
Runtime.OriginRequestError or Runtime.RequestTimeout. The status classes count the platform pages too,
except the 400, 404 and 505 pages. Each environment has a datapoint at init, also a failed one, then
one each minute and one when it ends.

* fix(lambdaweb): bound the waiting metric writes and store them before shutdown

* fix(lambdaweb): report each answer before it goes out and build datapoints with MetricDatum.of

A test can then wait for the publisher once and read the metrics without polling. RDS and SES build
their datapoints with the same factory.

* fix(lambdaweb): wait for the metric writes even when their queue is full

The wait now takes the last accepted write instead of a slot in the queue.
The writes run one at a time in order, so once it is done all are.
Only PutMetricData stores a zero timestamp as the current time, so the
MetricDatum.of comment says so.
2026-10-19 10:22:15 -04:00
TATSUNO “Taz” Yasuhiro b6bc3032f1 fix(lambdaweb): report init failures as AWS does (#5960)
* fix(lambdaweb): tell why a Web Function app failed to start as AWS does

An app that exits at start with a status other than 0 now gets Runtime.ExitError, and an app that cannot find a module at import gets Runtime.ImportCodeError. A failed import writes the one ERROR event AWS writes in place of Node's stack.

* fix(lambdaweb): read the init error type from a file so any exit status keeps its meaning

* fix(lambdaweb): write the init error type where any user can

* fix(lambdaweb): clear an init error type left in the runtime image
2026-10-18 21:21:28 -04:00
TATSUNO “Taz” Yasuhiro 301ac79c6e feat(lambdaweb): write the platform events of Web Function environments (#5936)
* feat(lambdaweb): write the platform events of Web Function environments

Each environment now writes the platform.* events AWS writes, filtered by the revision's systemLogLevel. CPU time and memory come from the container's cgroup. The output of an environment that fails before it listens reaches its stream too. Node runs under Docker's init, so a server without a SIGTERM handler stops at once, as on AWS where it is not PID 1. The server has 9 seconds to listen, as the AWS TimeoutListenError message says.

* fix(lambdaweb): settle the platform events of an environment that ends early

The last reports wait for the requests the exit failed, so they are counted. A periodic summary comes no more after the last report. An exit right after the app listens is handled as an exit. The CPU time counts on a host without memory.peak. The listen failure event is dropped at applicationLogLevel FATAL, as on AWS.
2026-10-18 11:09:24 -04:00
TATSUNO “Taz” Yasuhiro 8067ecf1de feat(lambdaweb): send what a Web Function writes to its log groups as AWS does (#5919)
* feat(lambdaweb): send what a Web Function writes to its log groups as AWS does

* chore(lambdaweb): write the Web Function runtime as an ES module

* fix(lambdaweb): create a log group or stream only when an event finds it missing

* fix(lambdaweb): cut a log line by its UTF-8 size after replacing bytes that are not UTF-8

* test(lambdaweb): wait for the last log line instead of a fixed sleep
2026-10-18 09:23:06 -04:00
TATSUNO “Taz” Yasuhiro 5eb4eecf99 feat(lambdaweb): enforce IamAuth on Web Function endpoints (#5855)
* fix(lambdaweb): accept role and user ARNs as resource policy principals

AWS checks an ARN principal against a pattern that allows a slash, so a
role or user ARN passes. Any other AWS principal value is still checked
against the pattern without a slash.

* feat(lambdaweb): verify SigV4 and InvokeWebFunctionEndpoint on IamAuth endpoints

An IamAuth endpoint takes a request signed for the service lambda in the
endpoint's region, in the Authorization header or a presigned query. The
X-Amz-Content-SHA256 header is required and is the payload hash, as on
AWS. A refused request gets the AWS 403 page with no error type. The
check runs after the rateLimit 0 page and before the rate limit.

Under IAM enforcement the signer also needs
lambda:InvokeWebFunctionEndpoint on the endpoint ARN from its identity
policy or the function's resource policy, with the auth type and the
function tags as condition keys.

An Authorization that is an AWS signature is dropped before the app on
every endpoint, together with X-Amz-Security-Token.

* fix(lambdaweb): give the app the path without dot segments and sign only the normalized path

Lambda removes dot segments before the app sees the path, on every
endpoint, and keeps repeated slashes and encoded dots. An IamAuth
signature counts only over the path as signers normalize it. A signature
over the path as sent is refused when the two differ. Floci forwarded
the path as sent and took a signature over either form, so a request
signed for /a/c could reach the app as /a/./b/../c.

* fix(lambdaweb): answer 502 when the caller check fails inside Floci

A malformed date or query is still a refused signature. Any other
failure, such as in IAM storage, no longer looks like a 403. The endpoint
answers it with 502 and no error type, as AWS answers its own failures.

* fix(lambdaweb): check a principal against the ARN pattern only under AWS

Lambda allows a path only in an ARN under the AWS key. A CanonicalUser or
Federated value never matches that pattern.

* docs(lambdaweb): MultiRegion SigV4, presigned queries and dot segments on the way to the app

* chore(auth): share SigV4 signature parsing and age limits with API Gateway

The API Gateway authorizer and Lambda Web IamAuth read a SigV4 signature
from the Authorization header or a presigned query, and check its age, in
the same way. Both now use one record in core.common.auth. Each still
decides which placement wins and where it reads the session token, so
neither behaves differently.
2026-10-17 08:12:48 -04:00
TATSUNO “Taz” Yasuhiro c8de16ffc7 fix(lambdaweb): never run a request twice when the app crashes (#5842)
* fix(lambdaweb): retry a failed request only when Floci saw the exit before sending it

A request that found its environment dead was retried when Docker's exit
time came before the request start. Docker takes that time from the
daemon's clock, which can be seconds behind Floci's. So a request the app
had received could run a second time. Docker also reports an exit late
under load. Until then the dead environment stayed in the pool, and the
next request got a 503 too.

Floci now follows each environment with an attach stream. The stream ends
when the process exits, and Floci notes the time on its own clock. A
failed request waits for that, up to one second. It is retried only if
the exit came before it was sent. Otherwise it gets the 503 page after
the dead environment has left the pool.

* docs(lambdaweb): note the short window after an exit in the 503 row

* fix(lambdaweb): clean up an exited environment off the reaper thread

Docker can take seconds to report an exit status under load. On the
reaper this held up the rearm of dropped exit watches and the idle checks.

* test(lambdaweb): wait for Floci to see the exit instead of polling for the container
2026-10-16 21:44:24 -04:00
TATSUNO “Taz” Yasuhiro 832f1008bb feat(lambdaweb): scale environments per endpoint and apply maxEnvironments and rateLimit (#5785)
* feat(lambdaweb): scale environments per endpoint and apply maxEnvironments and rateLimit

Each endpoint keeps its own pool of environments, as on AWS. An
environment takes up to the revision's maxConcurrencyPerEnvironment
requests at once, the least busy one first so requests rotate, and a
request that finds every environment full starts another or waits for
one that is starting. At maxEnvironments the request gets the 429 page
with Platform.EndpointMaxEnvThrottle. A rateLimit admits a burst of up
to rateLimit requests refilled at rateLimit per second and refuses the
rest with Platform.EndpointRequestThrottle. Both pages were recorded
against AWS.

Part of #5699

* fix(lambdaweb): key environment pools by endpoint creation and let a new revision take an idle slot

A recreated endpoint gets a new domain, so it no longer reuses the
environments of the deleted one. At maxEnvironments an idle environment
of another revision is stopped to make room. Empty pools are dropped.
The burst in the Docker test now arrives at once, so a slow runner still
goes past the rate.

* fix(lambdaweb): keep the rate limiter clock monotonic and drop refilled buckets

A bucket untouched for a second is full, so it is dropped. A clock read
that lands behind the bucket no longer takes tokens back.
2026-10-16 07:10:39 -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 0492fc9842 feat(lambdaweb): CloudFormation types for Lambda Web Functions (#5722)
* feat(lambdaweb): CloudFormation types for Lambda Web Functions

AWS::Lambda::WebFunction, AWS::Lambda::WebFunctionRevision and
AWS::Lambda::WebFunctionEndpoint provision through the resource
registry. Ref of each is its ARN. Every property of a revision is
createOnly in the registry schema, so a changed revision mints a new one
and the displaced revision is deleted once the update commits. An
endpoint keeps its identity while its function, name, type and regions
stay the same. Fn::GetAtt on RegionalEndpoints is recorded as a gap.

Part of #5699

* fix(lambdaweb): compare a revision against the function's default log group

revisionMatches filled a request without a log group with the existing
revision's log group, so a template that dropped a custom log group kept
the old revision. The default is the function's log group, as when a
revision is created. replaceTags returns the updated function.

* fix(cloudformation): put a Lambda Web function or endpoint back after a failed stack update

A function's tags and an endpoint's mutable configuration are changed in
place on update. The provisioner now snapshots them before the change and
restores them from rollbackUpdate, as the other in-place provisioners do.
The function attributes after a tag update come from the updated
function, so UpdatedAt moves with the tag change.

* test(cloudformation): roll a Lambda Web stack update back after a failed revision

A revision that fails to create after the endpoint moved to a replaced
revision rolls the stack back. The endpoint returns to the kept revision
and the replacement is deleted. The doc page says that a CloudFormation
endpoint is always Disabled with RevisionWeights, since the schema has no
AutoDeploymentMode, and that a failed update puts in-place changes back.

* fix(cloudformation): refuse AutoDeploymentMode on a Lambda Web endpoint

The registry schema has no AutoDeploymentMode property and AWS fails a
template that sets it at validation. An endpoint from CloudFormation is
always Disabled and routes by RevisionWeights. Floci passed the property
through to the service, which accepted LatestRevision.

* refactor(lambdaweb): share the create and tag steps between the API and CloudFormation paths

createFunction and createFunctionShell both check the name and refuse a
duplicate under the function's lock. tagResource and replaceTags both
check the tags, lock, write, stamp and persist. Each pair now calls one
private helper, so the two paths cannot drift.
2026-10-15 19:02:50 -04: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