AWS Certified Developer – Associate (DVA-C02)Development with AWS ServicesEasy
A developer is building a serverless application that uses AWS Lambda functions to process user-uploaded images. The application needs to store temporary processing data, such as resized image versions, during the Lambda function's execution. This temporary data should not persist beyond the function invocation. Which of the following storage options is MOST appropriate and cost-effective for this use case?
- A/tmp directory on the Lambda execution environment
- BAmazon DynamoDB table
- CAmazon Elastic File System (EFS)
- DAmazon S3 bucket
Show answer & explanationAnswer & explanation
Correct answer: A. /tmp directory on the Lambda execution environment
The /tmp directory in the Lambda execution environment is designed for temporary storage during a function's invocation. It is ephemeral and suitable for data that does not need to persist, making it cost-effective and performant for this specific use case.
Why the other options are wrong
- B. Amazon DynamoDB is a NoSQL database for structured data storage, not suitable for temporary file system operations within a Lambda function.
- C. Amazon EFS provides persistent, shared file storage that can be mounted to Lambda, but it's overkill and more expensive for purely ephemeral processing data.
- D. Amazon S3 is for durable, long-term object storage and is not ideal for ephemeral, in-invocation temporary file system operations.
Lambda /tmp Directory
The /tmp directory is an ephemeral, local storage area available to AWS Lambda functions during their execution. It is cleared after the function invocation completes.
- Maximum size is 512 MB.
- Data does not persist across invocations.
- Ideal for temporary files like resized images or downloaded assets.
Memory trick: Temporary files in Lambda are 'tmp'-orary and disappear.