-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Support for golang lambda functions #561
Comments
+1, I'd be definitely interested in this |
In case in helps anyone else, I've worked around this for now by implementing a webhook wrapper around the lambda handler that simulates a direct sns->lambda invocation. It handles subscription confirmation requests, but as far as I've seen a confirmation request isn't ever sent by localstack. This example uses the gin framework for http handling:
|
Since we're already using the lambci Docker images for Java/Node/Python, it should be fairly straightforward to add support for Go. @wolfgangmeyers @HoneyryderChuck would you be able to look into into this? I'd be happy to help out where needed. This is a good starting point: |
@whummer Thanks for the help on this. I looked at lambda_executors.py and lambda_api.py, and after some digging, it seems that the runtime that is passed to lambci comes from the create_function api:
It appears that lambci is downloaded automatically by docker, so I think that should just work if the runtime is configured when creating the function. We might need to configure the correct executor here when the function code is updated:
|
I'll try to see if I can get this working when I have time |
@whummer I've made some progress. I've made some local changes so that the handler doesn't get a .py added to it, set up the LAMBDA_EXECUTOR=docker. The lambda executor seems to be attempting to use lambci now to run the task, but I'm hitting an error:
|
Similar issue reported here on a different project - aws/aws-sam-cli#274 |
I printed out the command that is running in order to launch docker:
Going to see if I can run this outside of localstack and get more details |
So I was able to take one of the stopped containers and recreate it with |
Docs for |
Looks like the problem is with the behavior of |
I think it worked...? I can't seem to get any kind of output from the task, just a statuscode. But the process seems to be executing normally now.
|
Initial support for Go Lambda functions added in #617 |
I'm having trouble with this feature, and was wondering if you'd encountered it or if there could be any clarity added to the documentation. I am using localstack inside a Docker container:
and a very simple golang lambda handler:
I compile the lambda function:
and then create a zip file:
I create the function and upload the zip file:
And then try to execute it:
And then it hangs for a while, nothing appears in the logs, and I see the message:
after 60 seconds. I'm able to run Python-based lambdas in localstack fine. |
@whummer I'm not sure when I will have time to dig into this, hopefully soon. I'd like to automate a simple test case like this to test the handler. Any thoughts on having the example script compile during the tests, or would it make sense to check in the binary, or host it somewhere else? |
Thanks @wolfgangmeyers 👍
Setting up a Go environment in CI seems like a bit of an overkill. The sample zipped Go program is roughly 2.9MB - I'd prefer not to check in files of this size into the main repo. I've created a new repo for test artifacts - can you please create a PR to add the binary here: https://github.com/localstack/test-artifacts |
@zbuc I was able to get your scenario to work in localstack.
Based on everything you listed, I think think this should work. What is your host operating system?
|
@whummer PR on the test artifacts repo - localstack-samples/localstack-pro-samples#1 |
Source code for the test application posted here - https://bitbucket.org/wolfgang_meyers/go_hello_lambda/src/master/ |
I am still facing this issue...response hangs and later response is
Any idea why would it happen?? here are the below Localstack logs: 2018-08-02T12:51:28:DEBUG:localstack.services.awslambda.lambda_executors: Running lambda cmd: CONTAINER_ID="$(docker create -e AWS_LAMBDA_FUNCTION_INVOKED_ARN="$AWS_LAMBDA_FUNCTION_INVOKED_ARN" -e AWS_LAMBDA_FUNCTION_NAME="$AWS_LAMBDA_FUNCTION_NAME" -e AWS_LAMBDA_EVENT_BODY="$AWS_LAMBDA_EVENT_BODY" -e HOSTNAME="$HOSTNAME" -e AWS_LAMBDA_FUNCTION_VERSION="$AWS_LAMBDA_FUNCTION_VERSION" -e LOCALSTACK_HOSTNAME="$LOCALSTACK_HOSTNAME" "lambci/lambda:go1.x" "pricing_occupancy_subscriber")";docker cp "/tmp/localstack/zipfile.25f94e16/." "$CONTAINER_ID:/var/task";docker start -a "$CONTAINER_ID"; the above line keeps on printing till the error appears please help!!! |
I too wasn't sure how to configure the YAML for a Golang lambda, found this very helpful write-up, and ran into a similar issue...
I was able to successfully 😃 resolve this by first downloading the Docker container that is being used to execute Go binaries...
|
I have pulled docker-image, but I still can't get it working ...
|
AWS now offers official support for golang lambda functions: https://aws.amazon.com/blogs/compute/announcing-go-support-for-aws-lambda/
Any idea on how to make these work with localstack? If they're not yet supported, where would be the best place to look if I wanted to add support?
The text was updated successfully, but these errors were encountered: