Closed RichDavis1 closed 4 years ago
We can close this.
For reference if anyone else encounters this, the problem stemmed from using actions/setup-go to configure the go environment at the beginning of my github actions workflow yaml.
I removed that step and just used the golang:alpine docker image and it worked great.
Also, if anyone encounters the problem where sam deploy can't find the location of the built binaries, you need to add ENV CGO_ENABLED=0
to your dockerfile.
@RichDavis1 Glad you were able to resolve this.
We do not look in GOROOT to find the go binary but instead look through the PATH on the system to try and find go. If you run into this again, you can also try adding where the go binary is to the beginning of the PATH. This should allow SAM CLI to pick this up.
Closing as the original poster solved the issue.
Description:
Trying to integrate sam build/sam deploy with github actions ci/cd for a golang project. When the Dockerfile in my .github workflow runs my entrypoint.sh script, which then calls
sam build
, the template file is recognized and the first function starts to build but then I get the following error:This process works fine locally from cli.
The closest ticket I've found to the situation I'm encountering: https://github.com/aws/aws-lambda-builders/issues/30
It appears that the lambda_builder validator is searching for the go executable in path
/usr/local/go/bin/go
when the github action setup-go has the executable atFound in cache @ /opt/hostedtoolcache/go/1.15.2/x64
causing this error to be produced.I guess my question is where, if possible, can I alter either the path that the BaseWorkflow looks for the golang executable or change my path in either the github action.yaml file/dockerfile?
Also, does BaseWorkflow use any go environment variables like GOROOT to search for the executable?
Steps to reproduce the issue:
Observed result: Fails to find the go executable path when calling sam build from entrypoint.sh when performing sam build.
Expected result: Successfully find the golang executable and builds the lambda functions/resources specified in template.yaml.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc) Snippet of my
.github/workflows/go.yml
:Dockerfile:
Full sam build --debug logs: