-
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 local invocation with CDK generated template not resolving dependencies in requirements.txt #1911
Comments
Given the debug logs, what are the contents of the Running |
I guess you mean the build?
If youre saying that Is there a way to force sam to use its own build directory for local invocations? Haven't found anything in the CLI reference about that. |
If the CloudFormation identifier for the function is The EDIT: I incorrectly stated we don't build |
I looked into this more. What is happening is when you do
Now due to this code we read asset:path and try to mount that src path in docker, which do not have installed dependencies. I don't have enough context on why this was done this way, I'll sync with Jacob tomorrow to understand and see if this is a bug or something else. Meanwhile as a work around in your Here is my output of local invoke:
|
@c2tarun Here is the context. When we were looking at supporting templates written in CDK, we only added support for One reason behind this was that we didn't want customers generating with CDK, then building and testing in SAM, and then going back to deploy in CDK. We wanted customers to generate and deploy with the same tool. If you do not follow this model, this would/could lead to "it working locally" but not when deployed. So the level of support we have for CDK is, If you are using CDK, use CDK for everything but local testing. @OFranke You might still be able to accomplish what you want. You could |
@jfuss
I totally understand that, but I am also kind of surprised that it sounds like there has never been the plan to integrate both tools in the long term. My uneducated guess was that what I was trying to achieve is absolutely the way to go for building a seamless dev experience from dev to prod. I checked what cdk is doing. It is indeed doing a build when bundling the asset, contained in But anyway, thank you for giving me so much insight. If that's not the intended way of sticking things together I guess I'll just fall back to docker for local dev. I'll close that one here. |
I wouldn't confuse long term with what our design choices were and why. We defiantly had the long term discussions with CDK and how we support each other. From CDK's point of view (at least from when we discussed this in the past), they wanted to introduce building lambda from within the CDK itself. The idea being that when you I would very much encourage you to reach out to CDK and ask for building Lambda in CDK directly. I still think that is a very valid thing for them to do. |
Was this ever resolved? The PRs I looked through were closed without any closing statements. The AWS docs show integration with SAM, but not building the dependencies correctly is a non-starter. |
Description
Local python dependencies are installed as defined but not found using local invoke. I am using CDK and SAM together, therefore my Cloud Formation file in
template.yaml
contains something like:It seems to work with the samples that are created using
sam init
. Those are usingType: AWS::Serverless::Function
in theirtemplate.yaml
filemy handler.py:
my requirements.txt
Steps to reproduce
I created a sample repository to reproduce the issue: https://github.com/OFranke/sam-cdk-bug. To reproduce run:
yarn
yarn build
cdk bootstrap
sam build
-> notice correct python pandas dependency in.aws-sam/build/pickletovizservicePickleToVizHandler68C6D6E2/pandas
sam local invoke
-> notice errorUnable to import module 'handler': No module named 'pandas'
Observed result
Expected result
successful invocation with response
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: tested with 0.47 and 0.37The text was updated successfully, but these errors were encountered: