AWS Lambda Go: ошибки VM при монтировании папки, /var/task/main нет такого файла или каталога. Как решить?

Я создал лямбду hellogo и попытался запустить ее локально, используя

sam package sam deploy sam local start-api с доступом: http://localhost:3000/hellogo

Докер имеет общую папку hellogo в настройках.

Во время доступа я вижу следующую ошибку от Docker. Что мне нужно сделать, чтобы решить эту проблему?

Fetching lambci/lambda:go1.x Docker container image......
2019-01-12 21:53:42 Mounting /Volumes/data/temp/aws-lambda-go-hello as /var/task:ro inside runtime container
START RequestId: 20099bdb-175d-10b0-c6dd-8acecddd82cd Version: $LATEST
END RequestId: 20099bdb-175d-10b0-c6dd-8acecddd82cd
REPORT RequestId: 20099bdb-175d-10b0-c6dd-8acecddd82cd  Duration: 1.26 ms   Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 6 MB   
{
  "errorMessage": "fork/exec /var/task/main: no such file or directory",
  "errorType": "PathError"
}
2019-01-12 21:53:43 Function returned an invalid response (must include one of: body, headers or statusCode in the response object). Response received: 
2019-01-12 21:53:43 127.0.0.1 - - [12/Jan/2019 21:53:43] "GET /hellogo HTTP/1.1" 502 -
2019-01-12 21:53:43 127.0.0.1 - - [12/Jan/2019 21:53:43] "GET /favicon.ico HTTP/1.1" 403 -

Больше деталей:

Сэм пакет

ML02:aws-lambda-go-hello pro$  **sam package** --template-file template.yaml --output-template-file packaged.yaml --s3-bucket prembucket01
Uploading to 60c9406899556856b732b3b1d556f0c2  1608 / 1608.0  (100.00%)
Successfully packaged artifacts and wrote output template to file packaged.yaml.

Сэм развернуть

ML02:aws-lambda-go-hello pro$  sam deploy --template-file packaged.yaml --stack-name aws-serverless-application --capabilities CAPABILITY_IAM

Waiting for changeset to be created..
Waiting for stack create/update to complete
Successfully created/updated stack - aws-serverless-application

сам местный старт-API

ML02:aws-lambda-go-hello pro$ sam local start-api
2019-01-12 21:51:10 Found credentials in shared credentials file: ~/.aws/credentials
2019-01-12 21:51:11 Mounting helloworld at http://127.0.0.1:3000/hellogo [GET]
2019-01-12 21:51:11 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2019-01-12 21:51:11  * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)

Я вижу ту же ошибку при развертывании в AWS

2 ответа

Есть некоторые связанные проблемы, такие как

Развертывание AWS Lambda с Go & Cloudformation и

https://github.com/serverless/serverless/issues/4710

попробуй сделать хендлера как

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

Попробуйте запустить образ докера локально и перейдите в /var/task/main, возможно, ваш бинарный файл имеет другое имя, чем main

Другие вопросы по тегам