我正在使用localstack:0.12.1
为AWS中设置的无服务器架构设置开发环境。基本上,我需要通过向订阅了SQS的主题发送SNS发布来执行Lambda,然后通过事件源映射到此SQS来触发Lambda。
所有资源均已成功创建并且可以相互通信。当我发送sns publish
命令时,它会按预期触发Lambda。但是我在代码执行时遇到了这个错误日志:
2020-11-05T19:34:25:DEBUG:localstack.services.awslambda.lambda_executors: Lambda executed in Event (asynchronous) mode, no response will be returned to caller
2020-11-05T19:34:25:INFO:localstack.services.awslambda.lambda_executors: Running lambda cmd: CONTAINER_ID="$(docker create -i -e NODE_ENV="$NODE_ENV" -e AWS_REGION_LOCATION="$AWS_REGION_LOCATION" -e EVENT_SUBSCRIBE_URL="$EVENT_SUBSCRIBE_URL" -e EVENT_TABLE_NAME="$EVENT_TABLE_NAME" -e EVENT_PUBLISH_URL="$EVENT_PUBLISH_URL" -e IDEMPOTENCY_TABLE_NAME="$IDEMPOTENCY_TABLE_NAME" -e IDEMPOTENCY_TABLE_TTL="$IDEMPOTENCY_TABLE_TTL" -e PARTNER_BOLETO_REGISTRY_ADAPTER="$PARTNER_BOLETO_REGISTRY_ADAPTER" -e DOCKER_LAMBDA_USE_STDIN="$DOCKER_LAMBDA_USE_STDIN" -e LOCALSTACK_HOSTNAME="$LOCALSTACK_HOSTNAME" -e _HANDLER="$_HANDLER" -e AWS_LAMBDA_FUNCTION_TIMEOUT="$AWS_LAMBDA_FUNCTION_TIMEOUT" -e AWS_LAMBDA_FUNCTION_NAME="$AWS_LAMBDA_FUNCTION_NAME" -e AWS_LAMBDA_FUNCTION_VERSION="$AWS_LAMBDA_FUNCTION_VERSION" -e AWS_LAMBDA_FUNCTION_INVOKED_ARN="$AWS_LAMBDA_FUNCTION_INVOKED_ARN" -e NODE_TLS_REJECT_UNAUTHORIZED="$NODE_TLS_REJECT_UNAUTHORIZED" --rm "lambci/lambda:nodejs12.x" "dist/interfaces/boleto-consumer.receiver")";docker cp "/tmp/localstack/zipfile.691f1954/." "$CONTAINER_ID:/var/task"; docker start -ai "$CONTAINER_ID";
2020-11-05T19:34:47:DEBUG:localstack.services.awslambda.lambda_executors: Lambda arn:aws:lambda:us-east-1:000000000000:function:financial-services-payment-boleto-registry-platform-local result / log output:
{"errorType":"CredentialsError","errorMessage":"Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1"}
> 2020-11-05T19:34:42.255Z undefined INFO {"context":{"applicationName":"boleto-registry-platform","contextName":"boleto"},"level":"info","datetime":"2020-11-05T19:34:42.255Z","message":"configProvider(): process.env.NODE_ENV: local","extra":{}}
> START RequestId: dddf0ad5-7cd4-151a-bd00-70af932a73c6 Version: $LATEST
> 2020-11-05T19:34:47.501Z dddf0ad5-7cd4-151a-bd00-70af932a73c6 ERROR Invoke Error {"errorType":"CredentialsError","errorMessage":"Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1","code":"CredentialsError","message":"Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1","errno":"ECONNREFUSED","syscall":"connect","address":"169.254.169.254","port":80,"time":"2020-11-05T19:34:47.495Z","originalError":{"message":"Could not load credentials from any providers","errno":"ECONNREFUSED","code":"CredentialsError","syscall":"connect","address":"169.254.169.254","port":80,"time":"2020-11-05T19:34:47.495Z","originalError":{"message":"EC2 Metadata roleName request returned error","errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"169.254.169.254","port":80,"time":"2020-11-05T19:34:47.494Z","originalError":{"errno":"ECONNREFUSED","code":"ECONNREFUSED","syscall":"connect","address":"169.254.169.254","port":80,"message":"connect ECONNREFUSED 169.254.169.254:80"}}},"stack":["Error: connect ECONNREFUSED 169.254.169.254:80"," at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)"]}
> END RequestId: dddf0ad5-7cd4-151a-bd00-70af932a73c6
> REPORT RequestId: dddf0ad5-7cd4-151a-bd00-70af932a73c6 Init Duration: 600.02 ms Duration: 3000.00 ms Billed Duration: 3000 ms Memory Size: 1536 MB Max Memory Used: 62 MB
lambda是否缺少在我的localstack
上正确执行的配置或角色?