-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda.go
43 lines (35 loc) · 830 Bytes
/
lambda.go
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
package main
import (
"context"
"github.com/aws/aws-lambda-go/lambda"
"github.com/relvacode/lambda-ddns/ddns"
"log"
"os"
"strings"
)
var handler *ddns.Handler
func init() {
securityGroupIds := strings.Split(os.Getenv("SECURITY_GROUP_IDS"), ",")
if len(securityGroupIds) == 0 {
log.Fatalln("No SECURITY_GROUP_IDS specified")
}
targetHostname := os.Getenv("TARGET_HOSTNAME")
if targetHostname == "" {
log.Fatalln("No TARGET_HOSTNAME specified")
}
awsRegion := os.Getenv("AWS_REGION")
if awsRegion == "" {
log.Fatalln("No AWS_REGION specified")
}
var err error
handler, err = ddns.New(securityGroupIds, awsRegion, targetHostname)
if err != nil {
log.Fatalln(err)
}
}
func HandleLambdaEvent(ctx context.Context) error {
return handler.Update(ctx)
}
func main() {
lambda.Start(HandleLambdaEvent)
}