Skip to content

AWS Lambda clear /tmp folder on Java17 Runtime

0

Hi! I'm working on my senior project that involves downloading files from github to the /tmp folder in lambda. Unfortunately that /tmp folder is not automatically cleared after every invocation, and because of that repository files are getting mixed up together. I have been trying to manually clear the folder, but nothing has worked so far, neither shell commands nor java code clears the folder properly. I try to clear it both before and after i'm done using the files, and nothing works.. Any help would be so appreciated!

asked 2 years ago1.4K views
1 Answer
0

This should help you understand the /tmp environment within Lambda. https://docs.aws.amazon.com/lambda/latest/operatorguide/execution-environment.html

Note: Delete any /tmp files before exiting, and use UUID naming to prevent different instances from accessing the same temporary files

Clearing the folder is not needed -- you gain efficiency on later invocations by leaving it there as cache. Only delete items that you specifically add (data) and name the files with UUID or other random names to avoid conflicts between invocations that may overlap.

Hope this helps!

AWS
EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.