In this video we are going to test and verify dynamic gdb streams event source mapping to lambda function.
For that purpose I'm going to create an item on order table.
Please open the administration console.
Go to order table and explore table items and let's create a new item with clicking this button.
So the ID will be one and I'm going to add some new string attributes.
For example, name, name could be an iPhone order and also add an existing attribute which is the status.
This is the order status I'm going to set as a in-progress and add any string attribute which could
be a date.
And basically we will create an order item into our order table and it includes name, status and delete
attributes.
And after that we will change the status after inserting item.
So let's create a new item on Dynamo DB and we expect that whenever we create item on Dynamo DB, this
will be streams to Dynamo DB streams and this will be received from the Lambda function and trigger
to our lambda function.
Click the Create Item button.
Our item is created successfully if you go to the function now.
So we expect that we should have one invocation which receives item from Dynamo DB because we have added
new item go to monitor and we in cloud watch logs.
And make sure that you have edit the log statement into lambda function code.
If you open the latest log stream, you can see that the invocation happens successfully and this is
the incoming event from the dynamic DB streams.
Please check that it is coming in the records array and we will we can receive the items in a batch
according to batch size.
And if you look at the attributes of the record, you can see the event.
The event name is a insert.
See that event name insert.
So that means we are creating a new item and if you scroll down you can see the event source dynamic
DB and dynamic DB attributes.
In here we are adding the item one and that is the attributes date name status, ID and status.
And you can see the additional details in this location.
Okay.
Basically, we will got this information from the cloud watch logs.
I'm going to copy this JSON.
And if you open the to the code, I have created a separate JSON file to to save this incoming event
JSON object to lambda function.
So I'm going to save for the insert statement in the event dash insert JSON and you can see the details
in here.
So now I'm going to update this item in Dynamic DB and see how these trigger to our lambda function.
If you come back to our dynamic DB table this time, I'm going to update an item, change the status
in progress to shipment.
So if you open the item.
And basically I have just changed so to improve the shipment and quality save changed and this will
trigger again our lambda function but this time this will be triggered the event of the update.
Click the save change.
And if you go back to our Lambda function and cloud watch settings, if you refresh this page.
Look it's mostly it is creating a new vocation looks at dream.
So I'm going to open looks again and open the log stream.
Latest log stream.
Yes.
This time we can see the second invocation comes in.
The first one is the insert event name and the second one.
You can see that this is the update and modify event name is the modify.
So let me copy this incoming event JSON object and paste into our.
We used to do code.
And if you come here and save as a JSON, you can see that we are modify, modify the existing item.
So that's why even name come modify an event source again dynamic DB streams and if you scroll down
you can see the new image in here.
New image.
We got the whole attributes with the new image.
So that's why you can see the old attributes now.
And the old image also comes in here because when we set a dynamic DB streams, the we've type is including
the new and old image pool.
So that's why you can see the old image as you can see that also is import case and so this is what
is comes in the logs and we can see the stream will type new and old image in the JSON format.
This is the insert command and this is the update command.
Okay.
As you can see that lambda pulling the events with event source mapping API from the Amazon dynamic
DB streams and we have seen all change data capture differences into our incoming event.
Some object of the lambda function.
Now it is time to develop our lambda function code.