Is it possible to access local filesystem in a AWS lambda function? If so, is there any downside to doing so?
Since customers could not cache larger data locally in the Lambda execution environment, every function invoke had to read data in parallel, which made scaling out harder for customers. Today, we are announcing that AWS Lambda now allows you to configure ephemeral storage ( /tmp ) between 512 MB and 10,240 MB.
I am very happy to announce that AWS Lambda functions can now mount an Amazon Elastic File System (Amazon EFS), a scalable and elastic NFS file system storing data within and across multiple availability zones (AZ) for high availability and durability.
An EFS is a file system that you can mount from different instances, including a Lambda function. One major caveat is that all these resources should be in the same security group and VPC (Virtual Private Cloud).
It is possible. I have python function that does something like
localFilename = '/tmp/{}'.format(os.path.basename(key)) s3.download_file(Bucket=bucket, Key=key, Filename=localFilename) inFile = open(localFilename, "r")
Be sure you are using it for temporary storage and not to maintain any state. Depends on what you are trying to do.
From AWS Lambda Execution Context:
Each execution context provides 512 MB of additional disk space in the /tmp directory. The directory content remains when the execution context is frozen, providing transient cache that can be used for multiple invocations. You can add extra code to check if the cache has the data that you stored. For information on deployment limits, see AWS Lambda Limits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With