A developer is building a serverless application consisting of multiple AWS Lambda functions written in Python. Each function needs to use the same large, third-party utility library as well as a shared custom logging module. The developer wants to optimize the deployment process by minimizing the deployment package size of the individual Lambda functions and centralizing the management of these shared dependencies. Which approach should the developer use to meet these requirements with the least operational overhead?
- Package the shared utility library and the logging module into an AWS Lambda layer, upload the layer, and configure each Lambda function to reference this layer.Cevap
- BUpload the shared libraries to an Amazon S3 bucket, configure the Lambda function's IAM trust policy to grant read access to the S3 bucket, and download the libraries at runtime.
- CWrite code inside the Lambda handler function to download the library from a public repository into the /tmp directory using pip during each execution.
- DDeploy the Lambda functions inside a private VPC subnet to access an Amazon Elastic File System (EFS) containing the libraries, without configuring a NAT Gateway or VPC endpoint.
Cevap
Package the shared utility library and the logging module into an AWS Lambda layer, upload the layer, and configure each Lambda function to reference this layer.
AWS Lambda layers are designed to isolate and share common dependencies across multiple Lambda functions. This centralizes dependency management, reduces deployment package sizes, and optimizes deployment workflows.
Adım Adım Çözüm
Anahtar Kavram
AWS Lambda Layers dependency management
Tahmini Süre:1m 30s