Reputation: 85
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;
}
Upvotes: 3
Views: 702
Reputation: 12538
The main way I'm aware of debugging with AWS Lambda is to use debug output logging to CloudWatch. AWS provides a C# Logging documentation.
context.Logger.Log("My debug log!");
You might try to pass your record into that.
context.Logger.Log(var.EventSourceArn);
might print something out otherwise check the documentation on what else could be available.
Upvotes: 1