A developer has implemented an AWS Lambda function that processes PDF documents uploaded to an Amazon S3 bucket. The function downloads each PDF to the local `/tmp` directory, extracts metadata, and updates a database. During high-volume load testing, several invocations fail with a 'No space left on device' error. Additionally, the developer observes that PDF files from previous invocations occasionally persist and interfere with current executions. Which combination of actions should the developer take to resolve these issues? (Select two.)
- Programmatically delete the downloaded PDF files from the `/tmp` directory before the function invocation completes.Answer
- Increase the ephemeral storage (`/tmp`) configuration of the Lambda function to support larger file sizes.Answer
- CConfigure Provisioned Concurrency for the Lambda function to guarantee that a new execution environment is initialized for every invocation.
- DSave the downloaded PDF files as global variables in the execution context instead of writing them to the `/tmp` directory.
- EDeploy the Lambda function inside a private subnet and configure an Amazon S3 Gateway VPC Endpoint to access the bucket.
Answer
To resolve the issues, the developer must programmatically delete the downloaded files from the local directory before execution completes, and increase the ephemeral storage configuration of the Lambda function.
The correct combination of actions involves programmatically deleting files from the local directory at the end of each invocation and increasing the function's configured ephemeral storage. Programmatic deletion ensures that files do not accumulate over multiple invocations that share the same warm execution environment, resolving both the data leakage and cumulative disk space consumption issues. Increasing the ephemeral storage configuration allows the function to use more than the default 512 MB of local storage to process larger files.
Step-by-Step Solution
Key Concept
Understanding AWS Lambda execution context reuse and configuring ephemeral storage.