-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sam build and sam local invoke differences regarding of LaverVersion in NodeJS #2222
Comments
Any progress? |
NB: the way that sam-cli handles layers is broken aws/aws-sam-cli#2222 - so... there's that
Any update on this? |
Hi all, This should have been fixed since I can't re-produce this issue locally. I have a function and layer in my
I am using
This is my source structure;
And after I run
And if I run
I am going to resolve this issue for now, but please let us know if you are still experiencing this issue with an example for us to reproduce it. Thanks! |
|
Description
ContentUri
property ofAWS::Serverless::LayerVersion
behaves differently depending on the command used and it is annoying.Currently, I have to use 2 different values, once to
sam local invoke
and another to runsam build
.Steps to reproduce
Here is the layer definition.
Notice I'm using
BuildMethod
to build the layer when invokingsam build
. Thedependencies-layer
folder looks like thisI can invoke
sam build
thensam deploy
and it works.Now if I try to invoke a function that depends on the layer, it won't find any packages. We all know that the structure for a NodeJS layer is as follow:
If I create the folder structure shown above, now
sam local invoke
works, but thensam build
fails because the folderdependencies-layer
does not contain apackage.json
.There are a few ways we can handle this, like creating the folder
nodejs
copying the package.json in it then invokingnpm install
beforesam local invoke
. Or having both structures so both versions of the commands are happy but then we will have to maintain 2 versions of package.json. Or using a symlink, or using, etc.Currently, I'm using a parameter, updated the value of
ContentUri: !Ref MyParam
and usingsam local invoke --parameter-overrides MyParam=./dependencies-layer
while the default value of the param isDefault: './dependencies-layer/nodejs'
but it feels like a hack.Expected result
I would like that they both get to a mutual agreement so we don't have to do any extra step to make it work. I'm talking about
sam build
andsam local invoke
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.2.0The text was updated successfully, but these errors were encountered: