Bug: Sam sync adds an extra nodejs directory to the path of the lambda layer
See original GitHub issueDescription:
We have a sam project with lambda functions and layers written in nodejs14.x. We are currently working on using sam sync to speed up development. When we start the project with sam sync it starts properly but the lambdas fail to use the functions provided in the layers. We started investigating the issue and downloaded the layer’s code with the following command: aws lambda get-layer-version --layer-name #LAYER_NAME# --version-number #LAYER_VERSION# --query Content.Location --output text
It turned out that when we use sam sync it adds an extra nodejs directory into the path of the layer. Layer content when deployed with sam deploy: layer.zip/nodejs/node_modules/…
Layer content when deployed with sam sync: layer.zip/nodejs/nodejs/node_modules/…
Steps to reproduce:
Create a layer with AWS::Serverless::LayerVersion and set the ContentUri to a local folder
Observed result:
sam sync adds an extra nodejs directory to the path of a nodejs14.x lambda layer
Expected result:
sam sync should create the same layer as sam deploy.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Windows 10
sam --version
: SAM CLI, version 1.60.0- AWS region: eu-west-1
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Thanks @mndeveci for the suggestion. I confirm that running
sam build
solves my issue.If you are running
sam build
beforesam package
and/orsam deploy
then it should work. I will try to prepare an example repo to show the difference.