Debugging AWS Serverless Lambda Functions with DynamoDBEvents in C#

Viewed 538

I am working on an AWS Serverless application with some Lambda functions that are fired from a DynamoDB trigger...

Basically when a new record in a DynamoDB table is entered...it triggers a LamdaFunction which reads in the parameters of the new record in the DynamoDBEvent parameter and then does some business logic and writes data to another DynamoDBEvents parameter.

How can I debug so I can see how to get the values out of the DynamoDBEvents parameter? Or what strategy can I use to achieve what I'm trying to do?

Is there a way to simulate a DynamoDBEvent from a VisualStudio Test project to all my function locally?

public APIGatewayProxyResponse AddUserTask(DynamoDBEvent dynamoEvent, ILambdaContext context)
{
    foreach (var record in dynamoEvent.Records)
    {
        //do stuff with the values from the new record in the dynamoEvent parameter...
    }

    var returnObj = new { Success = true };
    var response = new APIGatewayProxyResponse
    {
        StatusCode = (int)HttpStatusCode.OK,
        Body = SerializeObject(returnObj),
        Headers = new Dictionary<string, string> { { "Content-Type", "application/json" } }
    };

    return response;
}
1 Answers
Related