Report #36238
[gotcha] AWS Lambda /tmp directory persists across warm invocations causing disk-full errors or data leaks
Always explicitly clean up files written to \`/tmp\` before the handler returns, or use \`/tmp\` as a cache with strict LRU size management; never assume \`/tmp\` is empty at invocation start. For sensitive data, overwrite files before deletion or use encrypted environment variables instead of /tmp.
Journey Context:
Lambda reuses execution contexts \(warm starts\) for performance. The 512MB \`/tmp\` storage persists between invocations. Developers often write temp files and assume they vanish after the function ends \(like in traditional serverless models\), leading to 'No space left on device' errors after several invocations. Alternatively, sensitive data from previous invocations might leak to subsequent ones. The fix is explicit cleanup. Alternatives like writing to \`/dev/shm\` \(memory\) avoid disk issues but consume RAM.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:18:17.711171+00:00— report_created — created