namespace BlueprintBaseName._1 open Amazon.Lambda.Core open Amazon.Lambda.DynamoDBEvents open System.IO open Newtonsoft.Json // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. [)>] () type Function() = let jsonSerializer = JsonSerializer() /// /// A simple function to print out the DynamoDB stream event /// /// /// /// member __.FunctionHandler (dynamoEvent: DynamoDBEvent) (context: ILambdaContext) = sprintf "Beginning to process %i records..." dynamoEvent.Records.Count |> context.Logger.LogLine let serializeStreamRecord streamRecord = use writer = new StringWriter() jsonSerializer.Serialize(writer, streamRecord) writer.ToString() let printRecord (record: DynamoDBEvent.DynamodbStreamRecord) = context.Logger.LogLine(sprintf "Event ID: %s" record.EventID) context.Logger.LogLine(sprintf "Event Name: %s" record.EventName.Value) context.Logger.LogLine("DynamoDB Record:") context.Logger.LogLine(serializeStreamRecord record.Dynamodb) dynamoEvent.Records |> Seq.iter printRecord context.Logger.LogLine("Stream processing complete.")