Lambda working even without layers #12141
Unanswered
yashk-aris
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Title: AWS Lambda Layer and Dependency Issue: Function Works Without Attached Layer
Problem Statement:
I'm encountering an issue with AWS Lambda layers and dependencies in my Serverless Framework project. Despite attaching a layer with common dependencies and explicitly excluding them from my deployment package, my Lambda function continues to work even when the layer is not attached.
Configuration and Deployment Details:
In my
serverless.yml
configuration, I have defined a Lambda function and attached a layer containing common dependencies like ajv and mysql2. I've also specified these dependencies as devDependencies in my package.json file and ensured that the node_modules folder is excluded from the deployment package.serverless.yml
for layers:lambda's .yml file:
serverless.yml
Layer Contents and Structure:
Inside the layer, I have organized the dependencies according to the following structure:
Package Command Output:
I have executed the serverless package command, and .serverless folder confirms that the
node_modules
folder is correctly excluded from my Lambda deployment package.I have also checked the lambda package from S3 bucket and there also I do find any
node_modules
folderLambda Execution Error:
When I test my Lambda function without the layer attached, I expect to encounter an Import Module Error, but instead, the Lambda function executes without any issues.
I have also manually created a lambda directly on AWS console. The lambda behaves as expected - Throws error in case the layer is absent.
Serverless Framework and AWS Lambda Version:
Dependency Management:
I have listed the dependencies (ajv, mysql2) as devDependencies in my package.json file and have properly excluded the
node_modules
folder from my deployment.I have reviewed the Serverless documentation and AWS Lambda documentation but haven't been able to identify the source of this issue.
I would greatly appreciate any insights, suggestions, or solutions to resolve this problem and ensure that my Lambda function relies on the attached layer for its dependencies.
Thank you for your assistance!
Beta Was this translation helpful? Give feedback.
All reactions