-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlambda.go
More file actions
63 lines (53 loc) · 1.56 KB
/
lambda.go
File metadata and controls
63 lines (53 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package cmd
import (
"github.com/urfave/cli/v2"
"github.com/lambda-feedback/shimmy/app"
"github.com/lambda-feedback/shimmy/app/lambda"
"github.com/lambda-feedback/shimmy/util/conf"
"github.com/lambda-feedback/shimmy/util/logging"
)
var (
lambdaCmdDescription = `The lambda command starts the shim as an AWS Lambda runtime
interface client, which allows it to be directly invoked by
the AWS Lambda runtime without any additional dependencies.
This command is intended to be used as the entrypoint for a
dockerized evaluation function, written in any language.
The command will start the AWS runtime interface client and
blocks indefinitely, processing incoming AWS Lambda events.`
lambdaCmd = &cli.Command{
Name: "lambda",
Usage: "Run the AWS Lambda handler.",
Description: lambdaCmdDescription,
Action: lambdaAction,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "lambda-proxy-source",
Usage: "the source of the AWS Lambda event. Options: API_GW_V1, API_GW_V2, ALB.",
Value: "API_GW_V2",
EnvVars: []string{"LAMBDA_PROXY_SOURCE"},
Category: "lambda",
},
},
}
)
func lambdaAction(ctx *cli.Context) error {
log, err := logging.LoggerFromContext(ctx.Context)
if err != nil {
return err
}
app, err := app.New(ctx)
if err != nil {
return err
}
cfg, err := conf.Parse[lambda.Config](conf.ParseOptions{
Cli: ctx,
})
if err != nil {
return err
}
log.Info("starting AWS Lambda handler")
return app.Run(ctx.Context, lambda.Module(cfg))
}
func init() {
rootApp.Commands = append(rootApp.Commands, lambdaCmd)
}