gpt4 book ai didi

amazon-web-services - 无法通过aws cli从localstack调用lambda函数

转载 作者:行者123 更新时间:2023-12-02 14:58:24 25 4
gpt4 key购买 nike

我已经推送了 lambda 函数,正如我在 localstack 中看到的那样,基于下面的命令/输出

 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 调用 --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:/var/run/docker.sock volume 运行 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

关于amazon-web-services - 无法通过aws cli从localstack调用lambda函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51803878/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com