You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
layers:
common-packages:
path: layers
description: Common packages like ajv, mysql2, pino and axios
compatibleRuntimes:
- nodejs14.x
- nodejs16.x
- nodejs18.x
compatibleArchitectures:
- x86_64
retain: true
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 folder
Lambda 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.
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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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