'Is there a way to change the 'scratch' (/tmp) space location of an AWS lambda function?

I'm grabbing some zip files from an S3 bucket and then converting them to gzip. The zipped files are about 130 megs. When uncompressed they are about 2 Gigs so I'm hitting the '[Errno 28] No space left on device' error.

Is it possible to use a different scratch space? maybe an EBS volume?



Solution 1:[1]

It's not possible. You only have a limited amount of space available to a single invocation of a Lambda function, and you can't add more space. It sounds like AWS Lambda isn't a good fit for your use case.

If you're looking for a more flexible serverless processing service, you might look into Iron.io, which actually runs on AWS.

Solution 2:[2]

The accepted answer is no longer accurate due to at least two new AWS features added since the posting. There are many configuration options and costs to consider, but both would work for the OP's needs.

  1. Lambda functions can now attach an Elastic File System (EFS) volume. Write to EFS instead of /tmp.
  2. Lambda functions now let you configure the size of /tmp. Simply increase the size to handle your largest expected file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Anonymous