In the last lecture, we retrieve all those information from our dynamodb table. In this lecture, what we are going to do, we are going to delete an inventory from the dynamodb table. So what we are going to do, we are going to create a new delete inventory function, which will delete inventory. Of course, we are going to keep the same runtime lambda 8.10 in this case and for permission we are going to use the same role that we had created earlier. So, once we have created this function, we are going to just reuse some code that we had previously created so we don't have to write it again and again. Now coming back to this SDK documentation.
We have a delete function which deletes an item From Dynamo DB and yes absolutely you guessed it right we need to have a key passed in this Param. So, then this SDK or this function is able to define what Id we are interested to delete. So little bit parents changes of course we are using we are going to use the same sort of environment variable configuration convention here. So, what we are going to do we are going to define key and key is no key is ID and which will come dynamically from the request body itself. dynamodb table here again environment variables so, let's let's reuse this environment variable and our table name is inventory. Of course some other ways when you when you are using kind of several this product we can have different kinds reusability to you know reuse this environment variable again and again.
In this case we are not much worried about at this point of time. So, once we have configured everything we are using the Delete function here, of course promise inside it and we are going to configure that delete event. In this case of course, we are going to pass an ID in the request body. So, this function can identify which I need which ID we need to delete. And in this case, we have calculated ID equals three Of course, we are not to worry about whether this idea is in dynamodb or not. And you can add this functionality on top of it.
So, once this has been executed, you will see this ID has been removed from your Dynamo DB records now, so, it was quite interesting and so far we have added crud functionality, how to add an inventory, how to update an inventory, how to read those all inventories and how to delete an inventory. So far, so good. It has come in quite interesting, we have created for micro services. And in the subsequent lectures we are going to create API's and how to consume that front end application. I'll see you in the next lecture.