Closed NRaf closed 6 years ago
Just ran into this same problem when putting together an example project using Node, Java and Python - hopefully this can be merged soon 🙂
Hey @ianrufus, will this conflict with PR #27? Out of curiosity, what's your use-case for SAM local vs the serverless framwork's serverless-offline plugin?
Can we add a test for this?
The serverless-offline plugin says it only works with NodeJS on the project readme - our work has been primarily in Java and Python, so we've been using SAM Local to use API Gateway with those runtimes locally. I've not had anything to do with the changes made by this PR, but I can try and take a look later this week if @NRaf doesn't have time
Submitting this PR to fix an issue I've encountered.
In my example, all my functions are written in Java however I had a use-case where I need one function written in NodeJS.
To get it to work with Serverless, I need to do the following:
runtime: java8
underprovider
.artifact
under the top-levelpackage
to the path of jar file for my Java functions.With these changes, everything works as expected when I deploy to AWS, however when I exported the SAM template and attempted to run it locally using
sam local-api
it would try to execute the NodeJS handler using the Java image.The reason for this is that the code that gets the
Runtime
andCodeUri
doesn't take into account parameters defined at a function-level.I've put in a simple fix to give precedence to the runtime and artifact set at a function level over the top-level runtime / artifact.