英文:
AWS Golang Lambda handler function not getting called
问题
我有一个类似于以下的 Golang 1.18 程序:
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/lambda"
)
func HandleRequest() error {
fmt.Print("HandleRequest entered\n")
return nil
}
func main() {
fmt.Print("Starting HandleRequest\n")
lambda.Start(HandleRequest)
}
我在 Linux 上编译了它,然后进行了 zip 压缩,并使用 Go1.x 运行时部署到 AWS Lambda。当我通过 AWS UI 进行“测试”时,我可以看到 Starting HandleRequest
的打印语句,但我看不到 HandleRequest entered
的打印语句。在日志中,我看到了一行类似于 Task timed out after 30.03 seconds
的内容。
我不知道为什么会超时,或者为什么需要 30 秒才能开始调用 HandleRequest
。根据 https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html#golang-handler-signatures 中的说明,处理程序函数的签名应该是有效的。
有什么想法吗?谢谢。
英文:
I have a Golang 1.18 program like:
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/lambda"
)
func HandleRequest() error {
fmt.Print("HandleRequest entered\n")
return nil
}
func main() {
fmt.Print("Starting HandleRequest\n")
lambda.Start(HandleRequest)
}
Which I've compiled in Linux, zip'ed up, and deployed to AWS Lambda with Go1.x runtime. When I "Test" my lambda via AWS UI, I see the Starting handleRequest
print statement, but I don't see the handleRequest entered
print startment. In the logs I see a line like Task timed out after 30.03 seconds
.
I have no clue why it is timing out, or taking 30 seconds in order to start calling handleRequest
. The handler function signature should be valid, according to https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html#golang-handler-signatures.
Any ideas? Thank you
答案1
得分: 1
原来我需要一个出站安全组规则来允许所有流量通过,尽管我不知道为什么(因为我没有发出任何出站请求)。
英文:
Turns out I needed an outbound security group rule to allow all traffic, although I dont know why (as I'm not making any outbound requests).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论