Skip to main content
AWS Lambda functions are ephemeral โ€” they spin up, run your code, and disappear. Any data written to /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

Add disk 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:
The 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.configure and archil.getDisk out 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 through disk.exec:
For the rare case where you need a low-level filesystem client running inside the Lambda โ€” for example, to stream a large fileโ€™s bytes through the Lambda โ€” see the @archildata/native package. It only ships binaries for Linux x64 and arm64 (both Lambda architectures are supported).