* feat(lambda): GetAccountSettings with usage-derived account limits Adds the Lambda GetAccountSettings operation. AccountUsage (total code size and function count) is derived from the caller's stored $LATEST functions in the region; AccountLimit reports the configured regional concurrency limit and its unreserved share after per-function reserved concurrency. * fix(lambda): widen the default Runtime API port pool to 12000-12499 One Runtime API port is held for the lifetime of each running Lambda container, so the width of the range is a hard ceiling on concurrent Lambda executions. The old default of 9200-9299 gave 100, which a multi-account AWS Landing Zone Accelerator deployment exhausts: it fans out several custom-resource Lambdas per account and can want well over a hundred at once. Exhaustion did not announce itself as a capacity limit either. The custom resource reported FAILED and CloudFormation rolled the stack back, so an operator saw an apparently unrelated CloudFormation error with no hint that a port pool was the cause. 12000 rather than a widened 9200 because the old range's tail collides with ports floci and its sidecars already use: 9200 is OpenSearch's own REST port, 9400-9499 is the OpenSearch host-binding pool, 9092 is Kafka and 9644 Redpanda's admin port. Both application.yml and the @WithDefault annotation are updated. application.yml is a config source, not a set of defaults, so a value set there wins over the annotation; changing only the annotation would have been a silent no-op (issue #2225). The new test asserts the two agree, so they cannot drift apart again. Refs #2206 * fix(lambda): make the Runtime API port-pool exhaustion error self-describing The old message did not name the pool, its width, or the property that widens it. It also rarely reaches an operator directly: the Lambda failure surfaces as a custom resource reporting FAILED and CloudFormation rolling the stack back, so this text is buried in floci's own log alongside a CloudFormation error that looks unrelated. The message now carries its own diagnosis — which pool ran dry, how many ports it had, that one port is held per running container so this is the concurrent-execution ceiling, and the two properties that widen it. Previously the only way to learn those knobs existed was to find this class in the source. Refs #2206 * feat(lambda): add ListFunctionsByCodeSigningConfig Net-new endpoint, GET /2020-04-22/code-signing-configs/{arn}/functions, always returns an empty FunctionArns list since this codebase has no CodeSigningConfig management (no Create/PutFunctionCodeSigningConfig), so no function can ever actually have one attached. Implemented as its own controller class with its own class-level @Path("/2020-04-22") rather than folding it into the existing LambdaCodeSigningController (/2020-06-30): a JAX-RS class-level @Path is load-bearing for route-matching priority, and stripping it to share one class across two API-version prefixes causes both endpoints to fall through to a more general catch-all route elsewhere in the app. * fix(lambda): scope code storage, publish-version counters, and S3 sync-reload to the owning account CodeStore resolved extracted code to baseDir/<functionName> with no account segment, so two accounts' same-named functions in one region shared a single on-disk directory and overwrote each other's package -- while codeObjectKey already wrote the same package to an account-prefixed S3 key. Cross-account invoke resolves a function by the ARN's own account, so a collision here silently serves one account's code under the other's ARN. The PublishVersion counter was keyed region+"::"+functionName and the delete path removed that same unscoped key; both now key on the owning account, via the shared ownerAccount() helper the S3 key already used. onS3ObjectUpdated runs on the CDI event thread with no RequestContext, so its ambient scan only ever saw the default account's partition and its save wrote back into that partition. It now lists across every account (keeping the region and $LATEST filters) and saves into the function's own account. listAll(), whose only caller is the startup concurrency rehydration, is broadened the same way so a restart no longer drops non-default accounts' reserved concurrency. Recovered from 613db7bd1, re-derived onto upstream's current shape: CodeStore's methods are re-signed rather than overloaded (the unscoped forms had no remaining consumer), and the sync-reload uses a new region-filtered listAllAccounts() instead of widening listAll() at that call site. * fix(lambda): carry persisted version counters across the account-scoped key change The counter map is persisted precisely so a restart cannot re-issue a version number that already names a snapshot. Re-keying it on the owning account made every pre-existing entry unreachable, so the next PublishVersion on an upgraded deployment would have started again at 1 and overwritten the live :1 snapshot. The counter now adopts and clears the pre-account key on a miss, and deleting a function clears both forms. Also covers the widened listAll(): the reserved-concurrency pool is per region and shared across accounts, so the startup rehydration that feeds it has to see every account or a restart silently frees capacity that steady-state PutFunctionConcurrency had already accounted for. * fix(lambda): validate CodeSigningConfigArn on ListFunctionsByCodeSigningConfig The handler took @PathParam("codeSigningConfigArn") and never read it, so any input — including "not-an-arn" — got a 200 with an empty FunctionArns array. It also dropped the modeled Marker/MaxItems query parameters. Botocore models InvalidParameterValueException (400) and ResourceNotFoundException (404) for this operation, and carries a pattern on the CodeSigningConfigArn shape: arn:(aws[a-zA-Z-]*)?:lambda:[a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1} :\d{12}:code-signing-config:csc-[a-z0-9]{17} (max 200 chars). That pattern is now applied verbatim, whole-string. The 404 for a well-formed ARN is a derivation, not an observation against real AWS: ResourceNotFoundException is modeled for this operation, the only resource the path parameter can name is a code-signing config, and Floci implements no CreateCodeSigningConfig / PutFunctionCodeSigningConfig — therefore every well-formed ARN necessarily names a config that does not exist. The previous always-empty 200 asserted the opposite (config exists, has no functions), which is the stronger and false claim. Validation order matches AWS: ARN shape, then MaxItems range (botocore MaxListItems: min 1, max 10000), then resource resolution — so a bad MaxItems is reported as such instead of being masked by the not-found. Marker is accepted and stateless: the result set is always empty, so no NextMarker is ever emitted. The pre-existing test asserted the 200-empty behaviour using an ARN whose csc- suffix was 9 characters, which the model's pattern rejects; it is replaced by six cases covering the two error classes and both MaxItems bounds. docs/services/lambda.md's two "always empty" claims are corrected to match. * docs(lambda): derive the operation count from the routed operations The branch adds two operations (GetAccountSettings and ListFunctionsByCodeSigningConfig) but bumped docs/services/index.md by one, 30 -> 31. Rather than hand-correcting to 32, the count was re-derived from the routes, because 30 could not be reconstructed from anything in the tree. index.md's own preamble states the rule for REST services: "the count reflects distinct AWS SDK operations, collapsing routes where one JAX-RS handler fans out via query-string or header markers". Counting JAX-RS methods across the Lambda controllers on upstream/main gives: LambdaController 24 LambdaConcurrencyController 3 LambdaEventInvokeController 5 LambdaLayerController 5 LambdaTagController 3 LambdaUrlController 4 -- 44 Two collapses applied. LambdaCodeSigningController's /2020-06-30 route and LambdaController's /2015-03-31 route are the same SDK operation (GetFunctionCodeSigningConfig) and count once. LambdaUrlInvocationController (5) and the lambda-package ApiGatewayController (5) are data-plane proxies with {proxy: .*} catch-alls, not Lambda SDK operations, so they are excluded. 44 + GetAccountSettings + ListFunctionsByCodeSigningConfig = 46. Corroboration that 44 is the real base and 30 is drift: docs/services/lambda.md's Supported Operations table lists 34 rows on upstream/main and omits exactly the 5 layer and 5 event-invoke operations — 34 + 10 = 44. Those 10 missing table rows are pre-existing and left alone here; only the count is in scope. * fix(lambda): match the current CodeSigningConfigArn pattern for isolated partitions The inlined regex predated the model's (eusc-)? prefix and widened -iso(b?) alternation, so a well-formed ARN in aws-iso-e/iso-f or the European sovereign cloud was rejected as malformed instead of reaching the modeled 404. * fix(lambda): validate FunctionName length, Role ARN, and Handler on config paths botocore models FunctionName up to 256 chars with dots allowed in the name segment; LambdaArnUtils rejected dots and never bounded length. Also close the gap where UpdateFunctionConfiguration accepted a malformed Role ARN or a whitespace-containing/oversized Handler and stored it verbatim. * fix(lambda): close leaked directory-listing streams and block dot-segment traversal in CodeStore Files.walk/Files.list returned streams that were never closed, leaking file descriptors and making delete() flaky on platforms that refuse to remove an open file. Separately, sanitizeName replaced disallowed characters but let a segment consisting entirely of dots (".", "..") pass through untouched, so an account or function name of exactly ".." resolved outside baseDir via Path.resolve instead of being rejected. * fix(lambda): reclaim pre-account-scoped code directories on delete and update A function created before code storage was account-scoped left its extracted code at <codePath>/<functionName>. DeleteFunction only ever targeted the new <codePath>/<accountId>/<functionName> path, and UpdateFunctionCode re-extracted to the new path without touching the old one, so the legacy directory (and its disk usage) lingered indefinitely after either operation. CodeStore now also clears the legacy path on delete, and re-extraction reclaims it on success. * fix(lambda): reject an explicit null Handler on UpdateFunctionConfiguration validateHandler treated null as "clear the handler", matching how Description is handled, but null is not a string at all -- and unlike Description, Handler names the file AWS invokes. A request with "Handler": null silently cleared it instead of failing with a 400, which would have broken every subsequent invocation of the function instead of the one bad request that caused it. * fix(lambda): do not reclaim a legacy code directory another account's function still uses The pre-account-scoped layout gave every account's same-named function the exact same on-disk directory. CodeStore.delete() and code re-extraction both reclaimed that legacy directory unconditionally once a function migrated to the account-scoped path, so a delete or code update in one account could destroy the legacy directory while another account's never-migrated $LATEST still served invocations from it -- its next cold start would then fail with a missing code directory. CodeStore.delete() no longer touches the legacy path at all; only LambdaService calls deleteLegacy() explicitly, after checking every account's $LATEST functions (via the existing cross-account listAllAccounts) for one still pointing its codeLocalPath at that directory. * fix(lambda): check published versions, not just $LATEST, before reclaiming a legacy code directory publishVersion snapshots codeLocalPath verbatim (required so a version-qualified invoke doesn't launch a container with no code, #1987), so a version published while $LATEST was still on the pre-account-scoped legacy path keeps that directory alive on its own after $LATEST migrates. The unused-check only scanned $LATEST records via listAllAccounts(region), so a later delete or code update reclaimed the directory out from under that published version's own future invokes. Switched to functionStore.listAll(), which has no $LATEST or region filter, matching the fact that the legacy path itself carries neither. * fix(lambda): close a publish-vs-legacy-cleanup race on the code directory publishVersion read codeLocalPath and persisted a snapshot of it with no synchronization against extractZipCodeBytes's/deleteFunction's decision to reclaim the pre-account-scoped legacy code directory (added inbede98fc1andf3837be32). A version could be published in the narrow window between that decision (finding no live reference) and the actual delete, persisting a snapshot whose codeLocalPath names a directory that is about to be removed -- its own future invocation would then fail with "Code directory not found". publishVersion and the reclaim call in extractZipCodeBytes now both take the same per-function lock deleteFunction already used for this. Proven with a test that holds the lock externally and asserts publishVersion blocks until it is released, rather than relying on timing to catch the race in the act.
34 KiB
Lambda
Protocol: REST JSON
Endpoint: http://localhost:4566/2015-03-31/functions/...
Floci Lambda runs your function code locally inside real Docker containers - close enough as AWS Lambda does (using Firecracker micro VM).
Supported Operations
| Operation | Description |
|---|---|
CreateFunction |
Deploy a Lambda function |
GetFunction |
Get function details and download URL |
GetFunctionConfiguration |
Get runtime configuration |
ListFunctions |
List all functions |
UpdateFunctionCode |
Upload new code |
UpdateFunctionConfiguration |
Update runtime, handler, memory, timeout, environment, architectures, tracing, layers, and more |
DeleteFunction |
Remove a function |
Invoke |
Invoke a function synchronously or asynchronously |
CreateEventSourceMapping |
Connect SQS / Kinesis / DynamoDB Streams to a function |
GetEventSourceMapping |
Get event source mapping details |
ListEventSourceMappings |
List all event source mappings |
UpdateEventSourceMapping |
Update a mapping |
DeleteEventSourceMapping |
Remove a mapping |
PublishVersion |
Publish an immutable version |
ListVersionsByFunction |
List all published versions of a function |
CreateAlias |
Create a named alias pointing to a version |
GetAlias |
Get alias details |
ListAliases |
List all aliases for a function |
UpdateAlias |
Update an alias |
DeleteAlias |
Delete an alias |
AddPermission |
Add a resource-policy statement |
GetPolicy |
Get the function resource policy |
RemovePermission |
Remove a resource-policy statement |
GetFunctionCodeSigningConfig |
Return code-signing config (always empty) |
ListFunctionsByCodeSigningConfig |
Validates the ARN; no code-signing config can exist, so every well-formed ARN returns ResourceNotFoundException |
CreateFunctionUrlConfig |
Provision a function URL |
GetFunctionUrlConfig |
Read function URL config |
UpdateFunctionUrlConfig |
Update function URL config |
DeleteFunctionUrlConfig |
Delete function URL config |
ListTags |
List tags on a function |
TagResource |
Tag a function |
UntagResource |
Untag a function |
PutFunctionConcurrency |
Set reserved concurrent executions |
GetFunctionConcurrency |
Get reserved concurrent executions |
DeleteFunctionConcurrency |
Clear reserved concurrent executions |
GetAccountSettings |
Account limits plus usage derived from the caller's stored functions |
Hot-Reloading via Reactive S3 Sync
Floci supports an automatic hot-reloading mechanism when functions are deployed via S3. This follows the standard AWS behavior where S3 and Lambda interact, but is optimized for a seamless local development experience.
When a Lambda function is created using an S3 bucket and key, Floci maintains a link between the function and its source object. Any subsequent update to that S3 object (e.g., via s3:PutObject) automatically triggers a reactive synchronization:
- Detection: Floci detects the S3 update via an internal event system.
- Synchronization: The new code is automatically re-extracted to the local code storage.
- Invalidation: Any active "warm" containers for that function are proactively drained.
- Reload: The very next invocation starts a fresh container with the updated code.
This allows you to update your Lambda code by simply re-uploading your ZIP to S3, without having to manually call UpdateFunctionCode or restart any containers.
Example
# 1. Create a function linked to S3
aws lambda create-function \
--function-name my-function \
--code S3Bucket=my-bucket,S3Key=function.zip \
...
# 2. Invoke (starts a warm container)
aws lambda invoke --function-name my-function out.json
# 3. Update the code in S3 (Triggers Reactive Sync)
aws s3 cp updated-function.zip s3://my-bucket/function.zip
# 4. Invoke again (automatically picks up the new code)
aws lambda invoke --function-name my-function out.json
!!! note "Standard Behavior" This mechanism requires no custom configuration or non-standard magic strings. It works with standard AWS SDKs and CLI tools, providing a "live" development feel while staying within the AWS API contract.
Hot-Reload via Bind Mount
For the tightest inner-loop development cycle, Floci supports a bind-mount hot-reload mode. Instead of packaging code into a ZIP and uploading it to S3, you point Floci directly at a directory on your host machine. The directory is bind-mounted into /var/task inside the container, so every invocation runs the files as they currently exist on disk, with no upload or redeploy.
This is enabled by using the magic bucket name hot-reload when creating a function:
aws lambda create-function \
--function-name my-function \
--runtime nodejs22.x \
--role arn:aws:iam::000000000000:role/lambda-role \
--handler index.handler \
--code S3Bucket=hot-reload,S3Key=/absolute/path/to/your/code \
--endpoint-url http://localhost:4566
The S3Key must be an absolute path reachable by the Docker daemon. When Floci runs in Docker Compose, this is the path on the Docker host (the machine running Docker), not the path inside the Floci container.
How it works
CreateFunctionwithS3Bucket=hot-reloadmarks the function as a hot-reload function;S3Keyis stored as the host-side path.- On each invocation, Floci starts a fresh ephemeral container with the host path bind-mounted at
/var/task. - The container executes the files as they exist at invocation time. Editing a file and immediately invoking picks up the change without any API call.
- After the invocation completes the container is stopped and removed, ensuring the next invocation always sees the current state of the directory.
Configuration
Hot-reload must be enabled explicitly. By default it is disabled so that S3Bucket=hot-reload is treated as a regular S3 bucket name.
FLOCI_SERVICES_LAMBDA_HOT_RELOAD_ENABLED=true
# Optional: restrict which host paths may be bind-mounted (comma-separated)
FLOCI_SERVICES_LAMBDA_HOT_RELOAD_ALLOWED_PATHS=/home/user/projects,/tmp
Docker Compose setup: enable the feature and share the Docker socket:
services:
floci:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
FLOCI_SERVICES_LAMBDA_HOT_RELOAD_ENABLED: "true"
Limitations
- The
S3Keypath is interpreted by the Docker daemon, not by Floci. When Floci itself runs inside Docker, the path must exist on the Docker host machine, not inside the Floci container. - Hot-reload containers are always ephemeral, so there is no warm-container reuse. Each invocation pays a cold-start penalty.
UpdateFunctionCodeon a hot-reload function converts it back to a standard Zip function (the hot-reload bind-mount is removed).- S3 reactive sync is skipped for hot-reload functions because edits are picked up directly from disk.
Difference from Reactive S3 Sync
| Reactive S3 Sync | Bind-Mount Hot-Reload | |
|---|---|---|
| Trigger | Upload a new ZIP to S3 | Edit files on disk |
| Cold start | Only after upload | Every invocation |
| Requires upload step | Yes | No |
Works without hot-reload enabled |
Yes | No |
| Path on host required | No | Yes |
!!! note "Concurrency enforcement"
Reserved concurrency is enforced: invocations beyond the reserved value
return TooManyRequestsException (HTTP 429). Functions without a reserved
value share a per-region pool. AWS Lambda's "account-level" limit is
in fact a per-account-per-region quota, and Floci mirrors that by
partitioning counters on the ARN's region segment. The pool size (default
1000) is configurable via floci.services.lambda.region-concurrency-limit
and applies independently to each region. PutFunctionConcurrency
validates that the requested value leaves at least
floci.services.lambda.unreserved-concurrency-min (default 100) available
for unreserved functions in that region. PutProvisionedConcurrencyConfig
and related provisioned-concurrency operations remain unimplemented.
Reducing or clearing a function's reserved value does not kill
invocations that are already in flight. This matches AWS, which
applies changes only to new invocations. As a consequence, during the
drain window `Σreserved-inflight + unreserved-inflight` can briefly
exceed `region-concurrency-limit`.
Function URLs are also reachable directly on /{proxy:.*} under the Lambda URL controller, which routes the request into the normal Invoke path.
Layers: PublishLayerVersion, GetLayerVersion, ListLayerVersions, ListLayers, and
DeleteLayerVersion are implemented, with real local storage under
{lambda.codePath}/layers/{name}/{version}. CreateFunction/UpdateFunctionConfiguration
validate each Layers ARN eagerly against that storage, matching real AWS - an unresolvable ARN
is rejected with InvalidParameterValueException, not silently accepted. Only resolves layers
published into this same local Floci instance; a real AWS-owned layer ARN (e.g. the AWS AppConfig
Extension or a Datadog-published layer) can never resolve here, since there's no mechanism in
Floci for fetching real AWS content - publish your own copy of the layer's content locally under
a name you control and reference that ARN instead.
Not Implemented
These AWS Lambda operations have no handler in Floci. Calls will return 404 or an error:
- Layer permissions and cross-account ARN lookup (
GetLayerVersionByArn,AddLayerVersionPermission,RemoveLayerVersionPermission,GetLayerVersionPolicy) - Provisioned concurrency (
PutProvisionedConcurrencyConfig,GetProvisionedConcurrencyConfig,ListProvisionedConcurrencyConfigs,DeleteProvisionedConcurrencyConfig) - Dead-letter, async invoke config, and event invoke config operations
InvokeWithResponseStream- Code signing management (only
GetFunctionCodeSigningConfigandListFunctionsByCodeSigningConfigare wired; there is noPutFunctionCodeSigningConfigorCreateCodeSigningConfig, so no code-signing config can exist andListFunctionsByCodeSigningConfigreports every well-formed ARN asResourceNotFoundException— a malformed ARN or an out-of-rangeMaxItemsis rejected withInvalidParameterValueExceptionfirst)
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_SERVICES_LAMBDA_ENABLED |
true |
Enable or disable the service |
FLOCI_SERVICES_LAMBDA_EPHEMERAL |
false |
Remove containers after each invocation |
FLOCI_SERVICES_LAMBDA_DEFAULT_MEMORY_MB |
128 |
Default function memory (MB) |
FLOCI_SERVICES_LAMBDA_DEFAULT_TIMEOUT_SECONDS |
3 |
Default function timeout (seconds) |
FLOCI_SERVICES_LAMBDA_RUNTIME_API_BASE_PORT |
12000 |
First port in the Lambda Runtime API range |
FLOCI_SERVICES_LAMBDA_RUNTIME_API_MAX_PORT |
12499 |
Last port in the Lambda Runtime API range. One port is held per running container, so the range width caps concurrent executions |
FLOCI_SERVICES_LAMBDA_CODE_PATH |
./data/lambda-code |
Directory where Lambda ZIP files are stored |
FLOCI_SERVICES_LAMBDA_POLL_INTERVAL_MS |
1000 |
Event-source mapping poll interval (milliseconds) |
FLOCI_SERVICES_LAMBDA_CONTAINER_IDLE_TIMEOUT_SECONDS |
300 |
Idle container shutdown timeout (seconds) |
FLOCI_SERVICES_LAMBDA_REGION_CONCURRENCY_LIMIT |
1000 |
Maximum concurrent executions per region |
FLOCI_SERVICES_LAMBDA_UNRESERVED_CONCURRENCY_MIN |
100 |
Minimum unreserved capacity PutFunctionConcurrency must leave |
FLOCI_SERVICES_LAMBDA_HOT_RELOAD_ENABLED |
false |
Enable bind-mount hot-reload via S3Bucket=hot-reload |
FLOCI_SERVICES_LAMBDA_HOT_RELOAD_ALLOWED_PATHS |
(unset) | Comma-separated allowlist of host paths that may be bind-mounted |
FLOCI_SERVICES_LAMBDA_DOCKER_NETWORK |
(unset) | Docker network to attach Lambda containers to (overrides FLOCI_SERVICES_DOCKER_NETWORK) |
FLOCI_SERVICES_LAMBDA_EXTRA_HOSTS |
(unset) | Comma-separated hostname:ip entries added to each Lambda container's /etc/hosts; ip may be host-gateway, mirroring docker run --add-host |
FLOCI_SERVICES_LAMBDA_DOCKER_HOST_OVERRIDE |
(unset) | Explicit host/IP that spawned Lambda containers use to reach Floci's Runtime API, bypassing auto-detection |
FLOCI_SERVICES_LAMBDA_CONTAINER_NAME_PREFIX |
floci |
Base name prefix for spawned Lambda containers and code volumes (e.g. acme → acme-<function>-<id> containers, acme-code-<function>-<hash> volumes). Must be a valid Docker name segment ([A-Za-z0-9][A-Za-z0-9_.-]*); invalid values are ignored with a warning |
FLOCI_SERVICES_LAMBDA_EXECUTOR |
docker |
Execution backend: docker (containers) or kubernetes (pods) |
FLOCI_SERVICES_LAMBDA_KUBERNETES_NAMESPACE |
default |
Namespace Lambda pods are created in |
FLOCI_SERVICES_LAMBDA_KUBERNETES_LABELS |
(unset) | Extra pod labels as comma-separated key=value entries |
FLOCI_SERVICES_LAMBDA_KUBERNETES_FLOCI_ADDRESS |
(unset) | Host/IP pods use to reach Floci; auto-detected when Floci runs in-cluster |
FLOCI_SERVICES_LAMBDA_KUBERNETES_INIT_IMAGE |
busybox:1.36 |
Init-container image that downloads function code (needs sh, wget, unzip) |
!!! note "Changing the container name prefix"
Code volumes are resolved by name, and a Floci process only manages resources under its
own prefix — deliberately, so multiple Floci processes with different prefixes can share
one Docker daemon without touching each other's containers and volumes. Restarting with a
different container-name-prefix therefore strands the code volumes (and their completion
markers) created under the previous prefix: they are no longer reused and no longer part of
automatic superseded-volume cleanup. They keep the prefix-independent floci=true label,
so reclaim them at any time with:
```bash
docker volume prune --filter label=floci=true
```
Runtime API host override
When a Lambda container starts, it calls back into Floci's Runtime API to fetch
events and post results. Floci auto-detects the address containers should use
for that callback (its own container IP on the shared network, or
host.docker.internal when running on the host). In most setups this is
correct and needs no configuration.
On unusual network topologies, for example rootless Podman, auto-detection
can pick an address the Lambda container cannot reach, and invocations fail with
connect ECONNREFUSED <ip>:12000. Set FLOCI_SERVICES_LAMBDA_DOCKER_HOST_OVERRIDE
to the host or IP that containers can actually reach Floci on, and Floci uses it
verbatim instead of auto-detecting:
FLOCI_SERVICES_LAMBDA_DOCKER_HOST_OVERRIDE=floci
See Docker Configuration → Running on Podman (rootless) for a full rootless Podman walkthrough.
Docker socket requirement
With the default docker executor, Lambda requires the Docker socket. Mount it
in your compose file:
services:
floci:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
If mounting the Docker socket is not acceptable (for example on a hardened Kubernetes cluster), use the Kubernetes executor instead — it needs no privileged access and no socket.
Kubernetes executor
Set FLOCI_SERVICES_LAMBDA_EXECUTOR=kubernetes to run each Lambda execution
environment as a Kubernetes pod instead of a Docker container. This is designed
for CI/CD clusters where privileged containers and docker.sock access are not
allowed. Floci talks to the cluster through the standard Kubernetes API: when
running inside the cluster it uses its ServiceAccount, and when running outside
it uses your local kubeconfig.
How an invocation works:
- On a cold start Floci creates a pod from the function's runtime image
(
public.ecr.aws/lambda/*, same mapping as the Docker executor). - An init container (
busyboxby default) downloads the function's deployment package — and any layers — from Floci's S3 over HTTP and unpacks them into sharedemptyDirvolumes at/var/taskand/opt. - The runtime container polls Floci's Lambda Runtime API
(
AWS_LAMBDA_RUNTIME_API) exactly like a Docker container would. - Warm pods are reused across invocations and reaped after
FLOCI_SERVICES_LAMBDA_CONTAINER_IDLE_TIMEOUT_SECONDSof inactivity. Pods left behind by a crashed Floci are swept on startup via theapp.kubernetes.io/managed-by=flocilabel.
Lambda pods connect back to Floci on the main port (4566) and the Runtime
API port range (9200–9299), so those ports must be reachable from pods in the
namespace. When Floci runs in-cluster this works out of the box (pod-to-pod
traffic); when Floci runs outside the cluster, set
FLOCI_SERVICES_LAMBDA_KUBERNETES_FLOCI_ADDRESS to an address the cluster's
pods can reach (for example your machine's LAN IP for a kind cluster).
Required RBAC
The ServiceAccount Floci runs under needs these permissions in the Lambda namespace. The manifest below is complete, so applying it as-is (together with the Deployment in the next section) yields a working setup:
apiVersion: v1
kind: ServiceAccount
metadata:
name: floci
namespace: floci
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: floci-lambda
namespace: floci
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["create", "get", "list", "watch", "delete", "deletecollection"]
- apiGroups: [""]
resources: ["pods/log"]
verbs: ["get", "watch"]
# Only needed when FLOCI_TLS_ENABLED=true (CA cert is shared via a ConfigMap)
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["create", "get", "update", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: floci-lambda
namespace: floci
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: floci-lambda
subjects:
- kind: ServiceAccount
name: floci
namespace: floci
Running Floci in-cluster
A minimal Deployment (namespace floci assumed, RBAC from above bound to the
floci ServiceAccount):
apiVersion: apps/v1
kind: Deployment
metadata:
name: floci
spec:
replicas: 1
selector:
matchLabels: { app: floci }
template:
metadata:
labels: { app: floci }
spec:
serviceAccountName: floci
# Required when a Service named `floci` exists in the namespace: service
# links inject FLOCI_PORT=tcp://<ip>:4566, which collides with Floci's
# FLOCI_* configuration convention and fails startup.
enableServiceLinks: false
containers:
- name: floci
image: floci/floci:latest
env:
- name: FLOCI_SERVICES_LAMBDA_EXECUTOR
value: kubernetes
- name: FLOCI_SERVICES_LAMBDA_KUBERNETES_NAMESPACE
value: floci
ports:
- containerPort: 4566
---
apiVersion: v1
kind: Service
metadata:
name: floci
spec:
selector: { app: floci }
ports:
- port: 4566
targetPort: 4566
Lambda pods reach Floci by pod IP, so the Runtime API ports need no Service entries; only clients of the emulator itself use port 4566.
Limitations
- Hot reload (both bind-mount and Reactive S3 Sync bind variants) and
FLOCI_SERVICES_LAMBDA_AWS_CONFIG_PATHrely on bind mounts and are not supported; hot-reload functions fail to launch with a clear error. Imagepackage type URIs are passed to the kubelet unchanged. Images in Floci's emulated ECR registry are not pullable by cluster nodes — pre-load them onto the nodes (e.g.kind load docker-image) or use a real registry.- Lambda pods carry no
imagePullSecrets. If your runtime or init images come from an authenticated registry, attach the pull secret to the namespace'sdefaultServiceAccount (kubectl patch serviceaccount default -p '{"imagePullSecrets":[{"name":"<secret>"}]}') so the kubelet uses it for every pod in the namespace. - A cold start waits up to 300 seconds for the pod to reach
Running(broken images and failing init containers are detected and reported much earlier). - The init container downloads code and layers over plain HTTP on the
emulator port even when
FLOCI_TLS_ENABLED=true. busyboxwgetcannot complete a TLS handshake with Floci, and the Runtime API traffic on the same pod network is plain HTTP anyway. Use a NetworkPolicy if the pod network is part of your threat model. - With
FLOCI_TLS_ENABLED=true, AWS SDK calls made from inside the function fail TLS verification when pods reach Floci by pod IP, because the self-signed certificate carries no SAN for dynamic pod IPs. SetFLOCI_SERVICES_LAMBDA_KUBERNETES_FLOCI_ADDRESSto a hostname covered by the certificate, or provide your own certificate viafloci.tls.cert-path. - Prefer an IP for
FLOCI_SERVICES_LAMBDA_KUBERNETES_FLOCI_ADDRESS. With a bare hostname, S3 SDKs inside functions may use virtual-hosted-style addressing (bucket.<hostname>), and nothing in the cluster resolves those subdomains. - IPv6-only clusters are not supported. Floci advertises an IPv4 address to pods and fails fast when none is available.
- Each Floci instance sweeps all
managed-by=flociLambda pods in its namespace at startup; run multiple Floci instances in separate namespaces. - Layers published by Floci versions before this feature have no stored archive; re-publish them once to make them downloadable by pods.
S3 virtual-hosted-style addressing inside Lambda containers
AWS SDKs use virtual-hosted-style S3 addressing by default, forming URLs like
https://my-bucket.s3.amazonaws.com/key. Against Floci the same pattern becomes
http://my-bucket.localhost.floci.io:4566/key.
When Floci runs inside Docker, Lambda containers are on the same Docker
network. Docker's embedded DNS resolves the exact alias localhost.floci.io
correctly, but has no wildcard support. my-bucket.localhost.floci.io
falls through to public DNS and resolves to the wrong IP, causing the Lambda
invocation to time out.
Floci solves this automatically by running an embedded DNS server (UDP/53) on its container IP. All Lambda containers launched by Floci are configured to use it as their DNS resolver. The embedded DNS server:
- Resolves
*.localhost.floci.io→ Floci's Docker network IP - Forwards all other queries to the upstream resolver(s) from
/etc/resolv.conf, falling back to public resolvers so public hostnames (e.g.business-api.tiktok.com) resolve from inside Lambda containers
No extra configuration or cap_add is needed because Docker containers have
CAP_NET_BIND_SERVICE in their default capability set, so Floci (running as a
non-root user) can bind UDP/53 without any changes to your Compose file.
VpcConfig, SnapStart and LoggingConfig
All three round-trip through CreateFunction, UpdateFunctionConfiguration,
GetFunctionConfiguration, GetFunction, ListFunctions and PublishVersion.
The response shapes are not the request shapes, and Floci follows the AWS model rather than echoing the request back:
| Field | Request shape | Response shape | Extra members Floci fills in |
|---|---|---|---|
VpcConfig |
VpcConfig |
VpcConfigResponse |
VpcId, resolved from the first subnet via EC2 |
SnapStart |
SnapStart |
SnapStartResponse |
OptimizationStatus — On only for a published version with ApplyOn=PublishedVersions, Off for $LATEST |
LoggingConfig |
LoggingConfig |
LoggingConfig |
— |
SnapStart and LoggingConfig are always present in a response, as on AWS: an
unset function reads back SnapStart={ApplyOn: None, OptimizationStatus: Off} and
LoggingConfig={LogFormat: Text, LogGroup: /aws/lambda/<name>}. With
LogFormat=JSON, ApplicationLogLevel and SystemLogLevel are also returned,
defaulting to INFO. Terraform treats these as Computed blocks, so a missing one
is a permanent diff rather than a cosmetic omission.
LoggingConfig is replaced wholesale on update, not merged — an update naming only
LogFormat resets LogGroup to the default.
LogGroup is validated against AWS's documented constraint: 1-512 characters matching
[.\-_/#A-Za-z0-9]+. ApplicationLogLevel and SystemLogLevel are accepted with any
LogFormat but are only ever stored — and therefore only ever returned — when the
resolved format is JSON; supplying them with LogFormat=Text is not an error, it is
simply a no-op, matching the fact that the response never surfaces them for Text.
VpcConfig is omitted entirely while the function is not attached to a VPC.
Subnets that EC2 does not know about are still accepted and returned; only VpcId
is left off in that case.
RuntimeVersionConfig.RuntimeVersionArn is returned for managed (non-image)
runtimes. Its value is derived from the runtime name, so it is stable across
restarts.
File system configs
FileSystemConfigs accepts one EFS access point and mounts it under the
requested /mnt/... path for local Lambda containers. As on AWS, the function
must include VPC subnet and security group configuration. The mounted path uses
the same shared-volume initialization settings as ECS EFS volumes under
floci.storage.efs.
This configuration is supported through the Lambda API, AWS::Lambda::Function
resources, and AWS::Serverless::Function resources.
S3 Files access points are not currently emulated and are rejected instead of being mounted as an empty local volume.
!!! note "Resolving public hostnames from Lambda"
A Lambda whose handler reaches a public host (fetch()/HTTPS to e.g.
business-api.tiktok.com) resolves it through Floci's embedded DNS. As a
safety net, Floci also appends configurable public resolvers (default
8.8.8.8, 8.8.4.4) after its own IP on each spawned container's DNS list,
so name resolution still works if the embedded forwarder cannot answer.
Tune or disable this for offline / locked-down networks where those resolvers
are blocked:
```bash
FLOCI_DNS_CONTAINER_FALLBACK_SERVERS=1.1.1.1,1.0.0.1 # use different resolvers
FLOCI_DNS_CONTAINER_FALLBACK_ENABLED=false # inject only Floci's DNS
```
!!! tip "Docker Compose service names"
If Floci runs as a Docker Compose service, set FLOCI_HOSTNAME to the
service name, for example FLOCI_HOSTNAME=floci. When no explicit Lambda
Docker network is configured, Floci automatically attaches Lambda
containers to the current Compose network. Floci then injects
AWS_ENDPOINT_URL=http://floci:4566 into Lambda containers and returns
SQS QueueUrl values with the same reachable host.
This avoids function-side rewrites from `localhost` or `localhost.floci.io`
to `floci`, and keeps normal AWS SDK clients pointed at the Docker DNS name
that the Lambda container can resolve.
!!! note "Path-style as a workaround"
If you cannot use virtual-hosted-style (e.g. Floci is running natively on
the host, not in Docker), configure the SDK client with
forcePathStyle: true / s3ForcePathStyle: true. Requests will go to
http://localhost:4566/my-bucket/key instead and work without DNS.
Migrating from LocalStack
If your Lambda functions have AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566
hardcoded, add the LocalStack suffix to Floci's DNS resolver so it resolves to
Floci's IP without any function-side changes:
Via environment variable, use a comma-separated list for multiple suffixes:
# Single suffix
FLOCI_DNS_EXTRA_SUFFIXES=localhost.localstack.cloud
# Multiple suffixes
FLOCI_DNS_EXTRA_SUFFIXES=localhost.localstack.cloud,localhost.example.internal
Real AWS Credentials
By default, a Lambda function whose execution role exists in Floci's IAM store receives temporary credentials for that role. SDK calls made by the function identify as assumed-role/<role>/floci-session, and IAM enforcement evaluates the role's policies. If the role is unknown to Floci, the container keeps the compatibility fallback described below.
For hybrid local/cloud testing, where some services are emulated and others hit real AWS, you can mount your host ~/.aws directory into Lambda containers:
services:
floci:
image: floci/floci:latest
environment:
FLOCI_SERVICES_LAMBDA_AWS_CONFIG_PATH: /Users/me/.aws
volumes:
- /var/run/docker.sock:/var/run/docker.sock
When aws-config-path is set:
- The host path is bind-mounted read-only into each Lambda container at
/opt/aws-config AWS_SHARED_CREDENTIALS_FILEandAWS_CONFIG_FILEenv vars are set so the SDK discovers credentials regardless of the container's HOME directory- No
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKENenv vars are injected
When unset (default), Floci injects execution-role credentials for a known role. For an unknown role, Floci reads credentials from its own environment and falls back to test/test/test.
!!! tip "Routing specific services to real AWS"
To keep some services on Floci while others hit real AWS, clear the global endpoint and set service-specific overrides in your function's --environment:
```
AWS_ENDPOINT_URL= # clear Floci's global endpoint
AWS_ENDPOINT_URL_SES=http://localhost.floci.io:4566 # SES stays on Floci
AWS_ENDPOINT_URL_CLOUDWATCHLOGS=http://localhost.floci.io:4566 # CloudWatch stays on Floci
```
The AWS SDK supports `AWS_ENDPOINT_URL_<SERVICE>` natively. Services without an override will use real AWS endpoints.
!!! note "Credential passthrough without mounting"
For functions whose execution role is unknown to Floci, you can pass static credentials to Floci's environment directly. When aws-config-path is unset, Floci forwards its own AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN env vars into those Lambda containers:
```yaml
environment:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_SESSION_TOKEN: ${AWS_SESSION_TOKEN}
```
A known execution role takes precedence over `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` values in the function environment. Use `aws-config-path` when the function must use mounted credentials instead of its emulated execution role.
Passthrough is on whenever those three variables are set in Floci's own environment, so a
Floci started from a shell that exports real AWS credentials (`aws-vault exec`, a sourced
credentials file, a CI runner) hands them to any function whose role it does not know. An
`AWS_PROFILE` or an `aws sso login` alone does not do this: those populate config and cache
files, not the environment. Floci logs a `WARN` carrying the forwarded access-key prefix the
first time it happens. Give the function a role Floci knows, or set `aws-config-path`, to keep
host credentials out of the container.
Private registry authentication
Container image functions ("PackageType": "Image") that pull from private registries need Docker credentials. See Docker Configuration → Private Registry Authentication for the full guide.
Examples
export AWS_ENDPOINT_URL=http://localhost:4566
# Package a simple Node.js function
cat > index.mjs << 'EOF'
export const handler = async (event) => {
console.log("Event:", JSON.stringify(event));
return { statusCode: 200, body: JSON.stringify({ hello: "world" }) };
};
EOF
zip function.zip index.mjs
# Deploy the function
aws lambda create-function \
--function-name my-function \
--runtime nodejs22.x \
--role arn:aws:iam::000000000000:role/lambda-role \
--handler index.handler \
--zip-file fileb://function.zip \
--endpoint-url $AWS_ENDPOINT_URL
# Invoke synchronously
aws lambda invoke \
--function-name my-function \
--payload '{"key":"value"}' \
--cli-binary-format raw-in-base64-out \
response.json \
--endpoint-url $AWS_ENDPOINT_URL
cat response.json
# Invoke asynchronously
aws lambda invoke \
--function-name my-function \
--invocation-type Event \
--payload '{"key":"value"}' \
--cli-binary-format raw-in-base64-out \
/dev/null \
--endpoint-url $AWS_ENDPOINT_URL
# Update code
zip function.zip index.mjs
aws lambda update-function-code \
--function-name my-function \
--zip-file fileb://function.zip \
--endpoint-url $AWS_ENDPOINT_URL
Event Source Mappings
Connect Lambda to SQS, Kinesis, or DynamoDB Streams:
# SQS trigger
QUEUE_ARN=$(aws sqs get-queue-attributes \
--queue-url $AWS_ENDPOINT_URL/000000000000/orders \
--attribute-names QueueArn \
--query Attributes.QueueArn --output text \
--endpoint-url $AWS_ENDPOINT_URL)
aws lambda create-event-source-mapping \
--function-name my-function \
--event-source-arn $QUEUE_ARN \
--batch-size 10 \
--endpoint-url $AWS_ENDPOINT_URL
ScalingConfig (SQS only)
CreateEventSourceMapping and UpdateEventSourceMapping accept a
ScalingConfig.MaximumConcurrency integer between 2 and 1000 on SQS
event sources, matching the AWS wire format. GetEventSourceMapping and
ListEventSourceMappings echo the value back when set; responses omit
the ScalingConfig field entirely when no cap is configured.
aws lambda create-event-source-mapping \
--function-name my-function \
--event-source-arn $QUEUE_ARN \
--scaling-config MaximumConcurrency=5 \
--endpoint-url $AWS_ENDPOINT_URL
Validation mirrors AWS: values outside 2–1000 are rejected with
InvalidParameterValueException, and ScalingConfig on a non-SQS event
source (Kinesis / DynamoDB Streams) is also rejected. Those services
use ParallelizationFactor instead, which is a separate field.
!!! note "Enforcement status"
The configured MaximumConcurrency is persisted and returned on the
wire, but the SQS poller does not yet cap concurrent invocations at
this value (the poller today serializes invocations per ESM to one
at a time regardless). Real parallel dispatch capped by
MaximumConcurrency is tracked as a follow-up.
Supported Runtimes
Any runtime that has an official AWS Lambda container image works with Floci (e.g. nodejs22.x, python3.13, java21, go1.x, provided.al2023).