forked from awsdocs/aws-doc-sdk-examples
/
main.go
29 lines (24 loc) · 752 Bytes
/
main.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
package main
import (
"context"
"fmt"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
func handler(ctx context.Context, e events.DynamoDBEvent) {
for _, record := range e.Records {
fmt.Printf("Processing request data for event ID %s, type %s.\n", record.EventID, record.EventName)
// Print new values for attributes of type String
// See
// https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/dynamodb@v1.0.0/types#AttributeValue
// for information on AttibuteValue.
for name, value := range record.Change.NewImage {
if value.DataType() == events.DataTypeString {
fmt.Printf("Attribute name: %s, value: %s\n", name, value.String())
}
}
}
}
func main() {
lambda.Start(handler)
}