Q80 — AWS DVA-C02 Ch.2
Question 80 of 100 | ← Chapter 2
A developer is designing a serverless application that includes two AWS Lambda functions for processing images. One Lambda function stores objects in an Amazon S3 bucket and stores associated metadata in an Amazon DynamoDB table. Another Lambda function retrieves objects from the S3 bucket using metadata retrieved from the DynamoDB table. Both Lambda functions use the same Python libraries to perform complex computations and are approaching the maximum deployment package size limit. To reduce the Lambda deployment package size, what should the developer do while minimizing operational overhead?
- A. Package each Python library into its own .zip file archive. Deploy each Lambda function with its own copy of the library.
- B. Create a Lambda layer containing the required Python libraries. Use this Lambda layer in both Lambda functions. ✓
- C. Merge the two Lambda functions into a single Lambda function. Deploy the Lambda function as a single .zip file archive.
- D. Download the Python libraries to an S3 bucket. Write the Lambda functions to reference the object’s URL.
Correct Answer: B. Create a Lambda layer containing the required Python libraries. Use this Lambda layer in both Lambda functions.
Explanation
Using a Lambda layer is an effective way to minimize Lambda deployment package size without increasing operational overhead. In this case, since both Lambda functions use the same Python libraries, creating a Lambda layer containing those libraries and using it in both functions avoids duplicating the same libraries in each function’s deployment package, thereby reducing overall package size. Other options may increase operational overhead or be less effective.