Open sambler opened 8 months ago
Hi @sambler Thanks for reporting the issue. Could you try building with the --use-container
flag and then deploying? I was able to access the dependencies installed through the layer when I did that. Additionally, do you know which version of SAM CLI last worked as you expected with the layers?
Meanwhile ill bring this up with the team to determine what we should be doing here
I don't have a linux setup to run docker, so --use-container
fails.
Just looked at my snapshots to check versions from a month ago
aws_sam_cli - 1.109.0 - now 1.110.0 aws_sam_translator - 1.84.0 - now 1.85.0 aws_lambda_builders - 1.45.0 - now 1.46.0 boto3_stubs - 1.34.32 - now 1.34.43 cfn_lint - 0.85.1 - now 0.85.2 ruamel.yaml - 0.18.5 - now 0.18.6
I faced the same issue when I executed sam deploy
with --template-file
and --config-file
options.
Upon downloading the contents of the Lambda layer, all I found was the source directory and not the artifacts directory.
But when I deployed without the --template-file
and --config-file
options the deployment was successful and the contents of the lambda layer had the artifacts directory in it.
In my case, this is not an issue which has occurred after a version update since this is a completely new deployment.
Environment: python3.9
aws-sam-cli: v1.118.0
A colleague of mine faced the same problem with v1.120
Can confirm what @varadkarpe said, the deploy seems to only package the ContentUri
source contents into the layer if the --template-file
option is passed. Without it, it seems like the proper built artifact is deployed.
Just to add some more context, using sam build
both with and without the --template-file
option produce the correct artifact output for the layer inside the .aws-sam/build/
folder.
aws-sam-cli: 1.124.0
Env: python3.10
Description:
When defining a layer in the template and using a makefile, the source dir is copied instead of the artifacts dir.
This changed recently, I think with the 1.110 update.
I am seeing this using the lambda python3.9 runtime.
Steps to reproduce:
Define layer in template
Makefile-
Observed result:
The source dir (mnsLayer) contains
Makefile
,requirements.txt
andutils.py
- these three files are found in the lambda runtime as/opt/Makefile
,/opt/requirements.txt
and/opt/utils.py
I can adjust my source to use the utils module with
but the extra modules in requirements are not found in the lambda runtime.
Locally,
.aws-sam/build/mnsLayer/python
contains the expected files, but they are not found in the lambda runtime.Expected result:
Previously this setup was installing
utils.py
so that it could be imported withimport utils
as well as extra modules in requirements being available.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.110.0Add --debug flag to command you are running
the portion of
sam build --debug
output that contains the layer build