【问题标题】:Why is handler script not found in this AWS Lambda deployment package?为什么在此 AWS Lambda 部署包中找不到处理程序脚本?
【发布时间】:2020-08-25 11:49:14
【问题描述】:

以下是来自https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.htmlgolang 示例 lambda 函数:

$ cat ./foo.go
package main

import (
  "fmt"
  "context"
  "github.com/aws/aws-lambda-go/lambda"
)

type MyEvent struct {
  Name string `json:"name"`
}

func HandleRequest(ctx context.Context, name MyEvent) (string, error) {
  return fmt.Sprintf("Hello %s!", name.Name ), nil
}

func main() {
  lambda.Start(HandleRequest)
}

我相信我已经正确地遵循了创建部署包的步骤:

$ GOOS=linux go build foo.go
$ zip foo.zip foo
  adding: foo (deflated 49%)
$

上面的 lambda 函数或者部署包有什么问题?如果没有,为什么 lambda create-function 会因为找不到处理程序脚本而失败?

$ aws --profile jack --endpoint-url http://localhost:4574 lambda create-function --function-name foo --runtime go1.x --zip-file fileb://foo.zip --handler main --role arn:aws:iam::000000000000:role/lambda-role

An error occurred (ValidationError) when calling the CreateFunction operation: Unable to find handler script (/tmp/localstack/zipfile.07e4ae91/main) in Lambda archive. Config for local mount, docker, remote: "False", "True", "True"
$

【问题讨论】:

    标签: amazon-web-services go aws-lambda localstack


    【解决方案1】:

    请查看以下 github 问题和 PR:

    在 localstack 中启用/使用 go 可能需要一些特殊步骤。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-05
      • 1970-01-01
      • 2022-06-19
      • 1970-01-01
      • 2015-10-24
      • 2019-04-20
      • 1970-01-01
      相关资源
      最近更新 更多