根据下面的命令/输出,我在localstack中看到了lambda函数
aws lambda get-function --function-name books1 --endpoint-url=http://localhost:4574
{
"Code": {
"Location": "http://localhost:4574/2015-03-31/functions/books1/code"
},
"Configuration": {
"Version": "$LATEST",
"FunctionName": "books1",
"CodeSize": 50,
"FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:books1",
"Environment": {},
"Handler": "main",
"Runtime": "go1.x"
}
}
当我尝试执行它时,如下所示,我得到一个错误,我的localstack正在docker容器内运行
AWS-Endpoint-url=http://localhost:4574 lambda invoke-function-name books1/tmp/output.json
An error occurred (InternalFailure) when calling the Invoke operation (reached max retries: 4): Error executing Lambda function: Unable to find executor for Lambda function "books1". Note that Node.js and .NET Core Lambdas currently require LAMBDA_EXECUTOR=docker Traceback (most recent call last):
File "/opt/code/localstack/localstack/services/awslambda/lambda_api.py", line 269, in run_lambda
event, context=context, version=version, asynchronous=asynchronous)
File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 466, in execute
process.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 462, in do_execute
result = lambda_function(event, context)
File "/opt/code/localstack/localstack/services/awslambda/lambda_api.py", line 390, in generic_handler
'Note that Node.js and .NET Core Lambdas currently require LAMBDA_EXECUTOR=docker') % lambda_name)
Exception: Unable to find executor for Lambda function "books1". Note that Node.js and .NET Core Lambdas currently require LAMBDA_EXECUTOR=docker
这个lambda是用go
编写的,当我在真正的AWS上手动执行它时,它工作得很好。
您应该使用传递的lambda_executor=docker
环境和/var/run/docker.sock:/code>卷运行localstack容器
docker run \
-itd \
-v /var/run/docker.sock:/var/run/docker.sock \
-e LAMBDA_EXECUTOR=docker \
-p 4567-4583:4567-4583 -p 8080:8080 \
--name localstack \
localstack/localstack