amazon-web-services - 为什么在此AWS Lambda部署包中找不到处理程序脚本?

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

以下是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"
$

最佳答案

请查看以下github问题和PR:

  • Support for golang lambda functions
  • Add golang support to lambda

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

    关于amazon-web-services - 为什么在此AWS Lambda部署包中找不到处理程序脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61704264/

    相关文章:

    Go package wincred 在将密码从 []byte 转换为字符串时添加空格

    google-app-engine - 从 AppEngine 上的上下文获取 *http.Request

    amazon-web-services - 如何授予Lambda访问AWS中的ElasticSearch的权限?

    python - Lambda 上的 MySQL 连接器产生无法导入模块 'myapp' : No module named 'mysql'

    amazon-web-services - Lambda throttle 场景

    amazon-web-services - 我可以通过从 EBS 切换到 EFS 存储来提高构建服务器的性能吗?

    amazon-web-services - aws cloudfront - S3 拒绝访问

    ubuntu - 使用 .pem 从 AWS Instance SSH 到 AWS Instance 要求输入密码

    java - emr如何在用户定义的函数中访问aws凭证

    postgresql - Golang GORM 中列的自动迁移问题