Configure ephemeral storage for Lambda functions - AWS Lambda

Configure ephemeral storage for Lambda functions

Lambda provides ephemeral storage for functions in the /tmp directory. This storage is temporary and unique to each execution environment. You can control the amount of ephemeral storage allocated to your function using the Ephemeral storage setting. You can configure ephemeral storage between 512 MB and 10,240 MB, in 1-MB increments. All data stored in /tmp is encrypted at rest with a key managed by AWS.

This page describes common use cases and how to update the ephemeral storage for a Lambda function.

Common use cases for increased ephemeral storage

Here are several common use cases that benefit from increased ephemeral storage:

  • Extract-transform-load (ETL) jobs: Increase ephemeral storage when your code performs intermediate computation or downloads other resources to complete processing. More temporary space enables more complex ETL jobs to run in Lambda functions.

  • Machine learning (ML) inference: Many inference tasks rely on large reference data files, including libraries and models. With more ephemeral storage, you can download larger models from Amazon Simple Storage Service (Amazon S3) to /tmp and use them in your processing.

  • Data processing: For workloads that download objects from Amazon S3 in response to S3 events, more /tmp space makes it possible to handle larger objects without using in-memory processing. Workloads that create PDFs or process media also benefit from more ephemeral storage.

  • Graphics processing: Image processing is a common use case for Lambda-based applications. For workloads that process large TIFF files or satellite images, more ephemeral storage makes it easier to use libraries and perform the computation in Lambda.

Configuring ephemeral storage (console)

You can configure ephemeral storage in the Lambda console.

To modify ephemeral storage for a function
  1. Open the Functions page of the Lambda console.

  2. Choose a function.

  3. Choose the Configuration tab and then choose General configuration.

    The Configuration tab in the Lambda console.
  4. Under General configuration, choose Edit.

  5. For Ephemeral storage, set a value between 512 MB and 10,240 MB, in 1-MB increments.

  6. Choose Save.

Configuring ephemeral storage (AWS CLI)

You can use the update-function-configuration command to configure ephemeral storage.

aws lambda update-function-configuration \ --function-name my-function \ --ephemeral-storage '{"Size": 1024}'

Configuring ephemeral storage (AWS SAM)

You can use the AWS Serverless Application Model to configure ephemeral storage for your function. Update the EphemeralStorage property in your template.yaml file and then run sam deploy.

Example template.yaml
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: An AWS Serverless Application Model template describing your function. Resources: my-function: Type: AWS::Serverless::Function Properties: CodeUri: . Description: '' MemorySize: 128 Timeout: 120 Handler: index.handler Runtime: nodejs22.x Architectures: - x86_64 EphemeralStorage: Size: 10240 # Other function properties...