What should the developer do to reduce the size of the Lambda deployment packages with the LEAST operational overhead?
Package each Python library in its own .zip file archive. Deploy each Lambda function with its own copy of the library.
Create a Lambda layer with the required Python library. Use the Lambda layer in both Lambda functions.
Combine the two Lambda functions into one Lambda function. Deploy the Lambda function as a single .zip file archive.
Download the Python library to an S3 bucket. Program the Lambda functions to reference the object URLs.
Explanations:
Packaging each Python library in its own .zip file and deploying them separately would not reduce the overall size of the deployment packages. Each Lambda function would still require its own copy of the library, leading to redundancy and larger sizes overall.
Creating a Lambda layer allows the developer to package the common Python library once and share it across multiple Lambda functions. This approach reduces the size of the individual deployment packages, as the library is stored separately and can be reused without duplication. It also minimizes operational overhead by avoiding the need to manage multiple copies of the same library.
Combining the two Lambda functions into a single function could lead to more complex code and reduced modularity. While it may reduce the number of deployment packages, it does not effectively address the issue of package size since the combined function would still need to include the entire library. This also reduces the scalability and flexibility of the architecture.
Downloading the Python library to an S3 bucket and referencing it from there introduces additional complexity and operational overhead. The Lambda functions would need to handle the download of the library at runtime, which can increase execution time and complexity, and is not an efficient solution for reducing deployment package size.