AWS Certified Developer – Associate / Question #1030 of 557

Question #1030

A developer has common libraries that several AWS Lambda functions must use. The developer packaged these libraries into a ZIP file. The developer needs to deploy the libraries to AWS and configure the Lambda functions to use them. Which solution meets this requirement in the MOST operationally efficient way?

A

Upload the ZIP file to Amazon S3. Configure the Lambda functions to reference the S3 bucket and key in their import statements.

B

Create a new Lambda function containing the libraries. Update the existing Lambda functions to invoke this new function synchronously.

C

Create a Lambda layer containing the ZIP file. Attach the layer to each required Lambda function.

D

Configure each Lambda function to mount an Amazon EFS file system where the libraries are stored.

Explanation

Answer C is correct because Lambda layers are specifically designed to centrally manage shared code and dependencies across multiple Lambda functions. By creating a layer containing the ZIP file of libraries and attaching it to each required Lambda function, the developer ensures that all functions can access the libraries without duplicating code. This approach simplifies updates (only the layer needs updating) and reduces deployment package sizes.

Other options are less efficient:
- A: Lambda cannot directly import libraries from S3; dependencies must be included in the deployment package or a layer.
- B: Invoking a separate Lambda function introduces latency, complexity, and unnecessary costs.
- D: Using EFS requires VPC configuration, adds network latency, and complicates setup compared to layers.

Key Points:
1. Lambda layers enable code/dependency sharing across functions.
2. Layers are more operationally efficient than S3, EFS, or inter-Lambda invocations.
3. Layers reduce redundancy and simplify version management.

Answer

The correct answer is: C