/tmp is lost between invocations. Archil gives your Lambda functions persistent, shared storage backed
by S3 without managing EFS or writing directly to the S3 API.
Lambda doesn’t support FUSE mounts, so the natural fit is the disk SDK — it’s pure
JavaScript, has no native dependencies, and gives you disk.grep for parallel
search and disk.exec for arbitrary commands, both run directly against
the filesystem without pulling data through the Lambda.
Install the SDK
Adddisk to your Lambda project:
Lambda handler
This handler runs a command against an Archil disk and returns the result — no data is ever copied through the Lambda:disk.grep call fans the search out across Archil-managed containers with the filesystem mounted;
only the matching lines come back to the Lambda. This is dramatically cheaper and faster than streaming
the underlying log files through the function, and it scales across many containers as logs grows
instead of being capped by a single one. For arbitrary commands beyond search, use
disk.exec instead.
IAM and credentials
disk calls the Archil control plane over HTTPS, which means it needs an API key. Set
ARCHIL_API_KEY (and optionally ARCHIL_REGION) on the Lambda function as an environment variable
or, better, pull it from AWS Secrets Manager during cold start.
The serverless exec containers themselves don’t need any AWS credentials configured on the Lambda
side — they run inside Archil’s infrastructure with the disk’s own data-source credentials.
Cold start considerations
disk is a thin HTTP client, so cold starts are dominated by the Lambda runtime itself rather than
SDK initialization. To minimize end-to-end latency:
- Hoist
archil.configureandarchil.getDiskout of the handler so warm invocations skip both:
- Choose a Lambda region close to the disk’s Archil region to minimize round-trip latency on control-plane calls.
- Increase Lambda memory if cold starts are slow — Lambda allocates CPU proportionally to memory, and TLS setup is CPU-bound.
Reading and writing files inside Lambda
If the Lambda needs to manipulate file contents directly (rather than dispatching work to the filesystem), the simplest approach is still to do it throughdisk.exec:
@archildata/native package. It only ships binaries
for Linux x64 and arm64 (both Lambda architectures are supported).