sam build fails with go+python template due to --use-container requirement for python
I have a multi-developer project that has several lambda functions. Some are written in Go and some are in Python. The python functions require a few native compiled libraries.
When building natively in codepipeline/travis/and on linux desktop using sam build works great since no -u (--use-container) is required to do the build. However, the Python developers all use Windows or OSX. They would like to use sam build -u to test their code before pushing up and triggering the C.I. pipelines.
sam build -u
Starting Build inside a container
Building resource 'CrmImportHandlerFunction'
Build Failed
Error: We do not support building Go Lambda functions within a container. Try building without the container. Most Go functions will build successfully.
The Go functions don't really need to be run by these particular developers but they do need to use sam build -u to build their own projects. It would be good if we could specify exactly which function we want to build so these users can build and test their functions.
Splitting the project is also a possibility, but it was super great to have these functions that share a lot of resources in the same template.
Possible suggestions:
.) Make it so you can specify to each run-time whether to use a container or not.
.) Have sam build -u build with containers when supported, but NOT use a container for unsupported function. This is best imo because everything would be allowed to succeed.
It would be good if we could specify exactly which function we want to build so these users can build and test their functions.
Usage: sam build [OPTIONS] [FUNCTION_IDENTIFIER]
You can specify just a function name.
Wow, sorry I must have had an older version on that machine or something. Thanks for pointing that out.
@sriram-mv That was a great tip, we have since found though that deploying with sam cli is still not possible.
Since sam build always clears the .aws-sam/build folder there isn't a way for a windows or osx user to end up with all the functions built for a deploy. Your suggestion works great for single local function invokes but it would be nice for these developers to be able to deploy more than 1 python lambda at a time (the others are missing from the build package since sam build -u <FuncName> deletes the previous builds and sam build -u fails on the Go builds.)
(Also the resulting template only has the correct codeuri for the function build that just ran)
I have the same problem, but its because I am using Python 3.8 and my linux box is on 3.7. I was using the -u because that handled the mismatch in python version. But when i just added my go function, i ran into the same issue. My solution is to create a python virtual environment with python 3.8. I can then run sam build and it will build both the go code and the python code for deployment.
I know this isn't a perfect solution because if you use python libraries that have binaries they may not run properly if built outside the container.
I don't know the specific version but at the time of writing, we do not support dotnet runtimes with container builds. Go has the ability to build in a container.
https://github.com/aws/aws-sam-cli/blob/develop/samcli/lib/build/workflow_config.py#L246
Closing as this is now supported.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.