Go语言的Serverless框架中的默认模板”aws-go”无法正常工作。

huangapple go评论72阅读模式
英文:

the default template for go lang "aws-go" in the serverless framwork isn't working

问题

大家好 Go语言的Serverless框架中的默认模板”aws-go”无法正常工作。 我是一个新手,我在使用Serverless框架部署的预构建的aws-go模板函数时遇到了问题。

不确定是否相关,但以下是关于我的系统的一些详细信息:

                   -`                    malup@mangulangot 
                  .o+`                   ----------------- 
                 `ooo/                   OS: Arch Linux x86_64 
                `+oooo:                  Host: GV62 8RD REV:1.0 
               `+oooooo:                 Kernel: 6.0.12-arch1-1 
               -+oooooo+:                Uptime: 20 hours, 51 mins 
             `/:-:++oooo+:               Packages: 1578 (pacman) 
            `/++++/+++++++:              Shell: zsh 5.9 
           `/++++++++++++++:             Resolution: 1920x1200 
          `/+++ooooooooooooo/`           DE: GNOME 43.2 
         ./ooosssso++osssssso+`          WM: Mutter 
        .oossssso-````/ossssss+`         WM Theme: Adwaita 
       -osssssso.      :ssssssso.        Theme: Juno-v40 [GTK2/3] 
      :osssssss/        osssso+++.       Icons: Adwaita [GTK2/3] 
     /ossssssss/        +ssssooo/-       Terminal: kitty 
   `/ossssso+/:-        -:/+osssso+-     CPU: Intel i5-8300H (8) @ 4.000GHz 
  `+sso+:-`                 `.-/+oso:    GPU: NVIDIA GeForce GTX 1050 Ti Mobile 
 `++:.                           `-/+/   GPU: Intel CoffeeLake-H GT2 [UHD Graphics 630] 
 .`                                 `/   Memory: 11563MiB / 15842MiB 

我有:

  • Node.js: v19.0.0
  • Go: go version go1.19.4 linux/amd64
  • AWS CLI: aws-cli/2.9.8 Python/3.9.11 Linux/6.0.12-arch1-1 exe/x86_64.arch prompt/off
  • Serverless框架:
Framework Core: 3.25.1
Plugin: 6.2.2
SDK: 4.3.2

我一直收到以下错误消息:

{
    "errorType": "Runtime.ExitError",
    "errorMessage": "RequestId: ac441b76-f8af-4565-9d46-8d8849efdf9c Error: Runtime exited with error: exit status 1"
}
Environment: linux, node 19.0.0, framework 3.25.1, plugin 6.2.2, SDK 4.3.2
Credentials: Local, "default" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Invoked function failed

以下是我部署函数的确切步骤:

  1. 在AWS控制台UI中使用“访问密钥 - 编程访问”作为凭证类型创建了一个IAM用户
  2. 点击“直接附加现有策略”并选中“AdministratorAcess”框,完成用户创建
  3. 运行aws configure并输入:
    • AWS Access Key ID
    • AWS Secret Access Key
    • 为区域输入us-east-1
    • 为输出格式输入json
  4. 运行serverless create -t aws-go -p backend创建名为backend的项目结构
  5. cd backend
  6. 运行go mod init backend创建mod文件
  7. 运行go mod tidy解决依赖关系
  8. 运行make
  9. 运行serverless deploy

没有发生错误,一切似乎都很正常。
现在我运行serverless invoke -f hello,然后我得到了那个错误消息。

如果我从AWS Lambda控制台点击“测试”按钮来测试该函数,它也会失败,并显示以下日志消息:

/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/bin/hello)
/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /var/task/bin/hello)
2022/12/17 21:44:41 exit status 1
/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/bin/hello)
/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /var/task/bin/hello)
2022/12/17 21:44:41 exit status 1
START RequestId: bdc3fd91-c5a8-4427-ab84-2eebba760853 Version: $LATEST
RequestId: bdc3fd91-c5a8-4427-ab84-2eebba760853 Error: Runtime exited with error: exit status 1
Runtime.ExitError
END RequestId: bdc3fd91-c5a8-4427-ab84-2eebba760853

请问我该如何解决这个问题?请帮帮我 Go语言的Serverless框架中的默认模板”aws-go”无法正常工作。

英文:

hello everyone Go语言的Serverless框架中的默认模板”aws-go”无法正常工作。 noob here, I am having trouble invoking pre-built aws-go template function that i have deployed using the serverless framework.

not sure if it's relevant but here some details about my system

                   -`                    malup@mangulangot 
                  .o+`                   ----------------- 
                 `ooo/                   OS: Arch Linux x86_64 
                `+oooo:                  Host: GV62 8RD REV:1.0 
               `+oooooo:                 Kernel: 6.0.12-arch1-1 
               -+oooooo+:                Uptime: 20 hours, 51 mins 
             `/:-:++oooo+:               Packages: 1578 (pacman) 
            `/++++/+++++++:              Shell: zsh 5.9 
           `/++++++++++++++:             Resolution: 1920x1200 
          `/+++ooooooooooooo/`           DE: GNOME 43.2 
         ./ooosssso++osssssso+`          WM: Mutter 
        .oossssso-````/ossssss+`         WM Theme: Adwaita 
       -osssssso.      :ssssssso.        Theme: Juno-v40 [GTK2/3] 
      :osssssss/        osssso+++.       Icons: Adwaita [GTK2/3] 
     /ossssssss/        +ssssooo/-       Terminal: kitty 
   `/ossssso+/:-        -:/+osssso+-     CPU: Intel i5-8300H (8) @ 4.000GHz 
  `+sso+:-`                 `.-/+oso:    GPU: NVIDIA GeForce GTX 1050 Ti Mobile 
 `++:.                           `-/+/   GPU: Intel CoffeeLake-H GT2 [UHD Graphics 630] 
 .`                                 `/   Memory: 11563MiB / 15842MiB 

i have

  • Nodejs: v19.0.0
  • Go: go version go1.19.4 linux/amd64
  • aws cli: aws-cli/2.9.8 Python/3.9.11 Linux/6.0.12-arch1-1 exe/x86_64.arch prompt/off
  • serverless framework:
Framework Core: 3.25.1
Plugin: 6.2.2
SDK: 4.3.2

i keep getting this error message

{
    "errorType": "Runtime.ExitError",
    "errorMessage": "RequestId: ac441b76-f8af-4565-9d46-8d8849efdf9c Error: Runtime exited with error: exit status 1"
}
Environment: linux, node 19.0.0, framework 3.25.1, plugin 6.2.2, SDK 4.3.2
Credentials: Local, "default" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Invoked function failed

here are the exact steps i have taken to deploy the function/s,

  1. created an IAM user name in aws console ui in the browser with Access key - Programmatic access as credential type
  2. clicked on Attach existing policies directly and checked the box for AdministratorAcess and finished creating the user
  3. ran aws configure and entered the
    • AWS Access Key ID
    • AWS Secret Access Key
    • entered us-east-1 for the region
    • and entered json for the output format
  4. ran serverless create -t aws-go -p backend to create a project structure called backend
  5. cd backend
  6. go mod init backend to create the mod file
  7. go mod tidy to resolve dependencies
  8. make
  9. serverless deploy

no errors have occurred and everything seemed fine.
now i run serverless invoke -f hello
and i get that error message

if i click on the Test button from the aws lambda console for the function it also fails with this is as the log message

/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/bin/hello)
/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /var/task/bin/hello)
2022/12/17 21:44:41 exit status 1
/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/bin/hello)
/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /var/task/bin/hello)
2022/12/17 21:44:41 exit status 1
START RequestId: bdc3fd91-c5a8-4427-ab84-2eebba760853 Version: $LATEST
RequestId: bdc3fd91-c5a8-4427-ab84-2eebba760853 Error: Runtime exited with error: exit status 1
Runtime.ExitError
END RequestId: bdc3fd91-c5a8-4427-ab84-2eebba760853

how do i go about resolving this issue please help Go语言的Serverless框架中的默认模板”aws-go”无法正常工作。

答案1

得分: 1

根据这个论坛上的指示,通过更改makefile文件解决了问题。

build:
	env CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o bin/hello hello/main.go
	env CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o bin/world world/main.go
英文:

solved by changing the make file according to the instructions on this forum
https://forum.serverless.com/t/hello-world-results-in-internal-server-error/13447

build:
	env CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o bin/hello hello/main.go
	env CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o bin/world world/main.go

huangapple
  • 本文由 发表于 2022年12月18日 05:50:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/74837704.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定