question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Sam sync adds an extra nodejs directory to the path of the lambda layer

See original GitHub issue

Description:

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)

  1. OS: Windows 10
  2. sam --version: SAM CLI, version 1.60.0
  3. AWS region: eu-west-1

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RobertMarton1985commented, Nov 2, 2022

Thanks @mndeveci for the suggestion. I confirm that running sam build solves my issue.

0reactions
mndevecicommented, Oct 28, 2022

If you are running sam build before sam package and/or sam deploy then it should work. I will try to prepare an example repo to show the difference.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sam sync - AWS Serverless Application Model
Resolves relative paths to the function's or layer's source code with respect to this directory. Use this option to change how relative paths...
Read more >
node.js - reading a packaged file in aws lambda package
I have a very simple node lambda function which reads the contents of packaged file in it. I upload the code as zip...
Read more >
Using AWS Lambda Layers with AWS SAM | SAM Series #5
Layers in AWS Lambda are used to pull in additional code such as external libraries, custom runtimes or other dependencies needed by your ......
Read more >
sam sync - Amazon Serverless Application Model - 亚马逊云科技
The prefix added to the names of the artifacts that you upload to the Amazon S3 bucket. The prefix name is a path...
Read more >
How to use AWS Lambda Layers with SAM - BlowStack
in the same template as the rest of resources. RULE #1. Nodejs folder have to be created as a parent folder for layer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found