In this video we are going to learn how to use a lambda with Amazon dynamic DB streams.
So Amazon Dynamic DB is integrated with a lambda so that we can create triggers and automatically respond
to events from the dynamic DB streams.
With triggers, we can build applications that react to data modifications in Dynamo DB tables.
If we enable Dynamo DB streams on a table, we can associate the streams.
Amazon Air run with the Amazon lambda function that we write with adding to trigger after adding the
trigger to lambda and dynamic DB streams emitted after an item in the table is modified.
Any record appears in the table's stream and a double lambda pulls the stream and invokes our lambda
function synchronously when it detects any stream records comes.
So remember that in the last video we will see the lambda function and pull based invocation from the
Amazon space and we will continue with the pull based event source mapping invocations.
But this time we will pull items from the Amazon dynamic DB streams.
When any table item is changed, we will capture the data change so the lambda function can perform
any actions that we specify.
For example, sending notification or initializing any workflow.
For example, we can write a lambda function to simply copy each stream record to persistent storage
such as the Amazon S3 and create a permanent audit trail and perform this kind of use cases in the lambda
functions so we can use a lambda function to process records in Amazon Dynamo DB streams.
With Dynamo DB streams, we can trigger a lambda function to perform additional work each time a Dynamo
DB table is updated.
Lambda reads the records from the stream and invokes our function synchronously with an event that contains
stream records.
So Lambda reads the code in a batch and invokes our function to process records.
From the batch you can see the example Dynamo, DB stream record, even JSON file in here it is again
coming from the records array and in the records array, every item represents a data change in the
dynamic DB streams, so Lambda Post charts in dynamic DB streams for records.
And after that, when the records are available, Lambda invokes our function and waits for a result.
If processing succeeds, Lambda resumes pulling until it receives more records by default.
Lambda invokes our function as soon as records are available on the stream pace we set that lambda pulls
the items from the dynamic DB streams when any data is changed from the Dynamo DB, but it has required
some permissions lambda need the permissions to manage resources related to dynamo DB streams.
We can see that these are the dynamic DB streams that we should provide execution role in the lambda
function which are the dynamo db describe stream, get records, get short iterated list streams.
This will be required for our lambda function in order to pull from the stream and process and invoke
the function and enable this.
There is a prebuilt configuration about the permission, which is the Lambda Dynamo DB execution role.
This is the manage policy that we can include our lambda function.
We will see in the upcoming videos.
So we will configure a stream as an event source of lambda function with the event source mapping and
pulling in locations.
So it is very easy to configuring stream as a even source of lambda.
We will create an event source mapping to tell them that to send records from our dynamic DB streams
to the lambda function, we can create multiple event source mapping to process the same data with multiple
lambda functions.
In order to configure our function to read from the dynamic DB streams, we can go to a case management
console, go to Lambda and we can create a trigger for dynamic DB streams.