
Answer-first summary for fast verification
Answer: Deploy the shared libraries, custom classes, and code for the API's Lambda functions to a Docker image. Upload the image to Amazon Elastic Container Registry (Amazon ECR). Configure the API's Lambda functions to use the Docker image as the deployment package.
The correct answer is D. Here’s why: The question asks for a solution to simplify the deployment of a serverless API and optimize code reuse using Amazon API Gateway and AWS Lambda. Option D suggests deploying the shared libraries, custom classes, and the code for Lambda functions into a Docker image. This Docker image is then uploaded to Amazon Elastic Container Registry (Amazon ECR). The Lambda functions are configured to use this Docker image as their deployment package. ### Explanation: 1. **Simplified Deployment**: - Using a Docker image for AWS Lambda functions simplifies deployment as everything (including shared libraries, custom classes, and function code) is encapsulated within the Docker image. This single image can be easily versioned, managed, and deployed across different environments. 2. **Code Reuse**: - By bundling shared libraries and custom classes within the Docker image, you ensure that all dependencies are included and consistent across all deployments. This promotes high levels of code reuse, as the same image can be referenced by multiple Lambda functions if needed. 3. **Alignment with Modern Practices**: - This approach aligns with modern practices of using containers to package and deploy applications. AWS Lambda supports container images, allowing for greater flexibility in terms of the runtime environment and dependency management. Using Docker images stored in Amazon ECR and configured within AWS Lambda combines the advantages of containerization (such as isolated environments, repeatable builds, and ease of dependency management) with the simplicity and scalability of AWS Lambda's serverless architecture.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A company is developing a new serverless API by using Amazon API Gateway and AWS Lambda. The company integrated the Lambda functions with API Gateway to use several shared libraries and custom classes. A solutions architect needs to simplify the deployment of the solution and optimize for code reuse. Which solution will meet these requirements?
A
Deploy the shared libraries and custom classes into a Docker image. Store the image in an S3 bucket. Create a Lambda layer that uses the Docker image as the source. Deploy the API's Lambda functions as Zip packages. Configure the packages to use the Lambda layer.
B
Deploy the shared libraries and custom classes to a Docker image. Upload the image to Amazon Elastic Container Registry (Amazon ECR). Create a Lambda layer that uses the Docker image as the source. Deploy the API's Lambda functions as Zip packages. Configure the packages to use the Lambda layer.
C
Deploy the shared libraries and custom classes to a Docker container in Amazon Elastic Container Service (Amazon ECS) by using the AWS Fargate launch type. Deploy the API's Lambda functions as Zip packages. Configure the packages to use the deployed container as a Lambda layer.
D
Deploy the shared libraries, custom classes, and code for the API's Lambda functions to a Docker image. Upload the image to Amazon Elastic Container Registry (Amazon ECR). Configure the API's Lambda functions to use the Docker image as the deployment package.