Home > front end >  AWS Lambda storage issue
AWS Lambda storage issue

Time:04-21

I got the following error when I ran python code on AWS lambda.

"errorMessage": "[Errno 17] File exists: '/tmp/testdir/'"

It occurs on the line os.makedirs('/tmp/testdir/').

Before I didn't have this kind of error. Does this mean Lambda function preserves tmp directory?

Should I clean tmp directory everytime?

CodePudding user response:

Yes, the content of the Lambda diskspace at /tmp may be available to subsequent Lambda invocations (these are so-called 'warm start' invocations).

See Understanding Container Reuse.

You can clean up the /tmp folder before existing your Lambda function or you could use the following code to safely create the folder, ignoring the fact that it may already exist:

os.makedirs('/tmp/testdir/', exist_ok=True)
  • Related