in handlers/dynamodb.go [57:79]
func eventFromDynamoDBRecord(record events.DynamoDBEventRecord) types.Event {
change, err := json.Marshal(record.Change)
if err != nil {
log.Fatalf("cannot unmarshal dynamodb record change: %s", err)
}
detailType := ""
switch record.EventName {
case string(events.DynamoDBOperationTypeInsert):
detailType = "ProductCreated"
case string(events.DynamoDBOperationTypeModify):
detailType = "ProductUpdated"
case string(events.DynamoDBOperationTypeRemove):
detailType = "ProductDelected"
}
return types.Event{
Source: "serverless-go-demo",
Detail: string(change),
DetailType: detailType,
Resources: []string{record.EventID},
}
}