In this video we are going to test product microservices synchronous flow with including the API Gateway,
Lambda function and dynamo DB table edge.
You remember that we have already provision all these services on the cloud and upload the lambda function
code in the product microservices.
So let's see in the main console, see that we have uploaded our lambda function code.
This is the our latest code.
And if you go to API Gateway, you can see the deployed API Gateway and these are the resource and HTTP
methods that expose from the API Gateway.
We will trigger these URLs and invoke lambda functions and lambda function.
Interact with the dynamic DB table to perform product microservices, cut operations.
Please open the Visual Studio code and remember that this is the our main folder structure and I have
created a postman folder.
If you expand this folder, you can see the product collection.
This is the postman collection that you can import this collection.
Let me open the postman.
If you come here and click the import statement and drag and drop in here, you can see these product
microservices HTTP methods that we can run one by one.
So let me start with the gate product.
These URLs get from the API gateway and I'm going to send a HTTP method, as you can see that this is
triggering the HTTP gate method and there is no product on product dynamo DB table yet.
So these HTP get triggered get all products.
So that means it is performed scan operation.
You can see that we run these get all product function.
Okay, if you come back to HTTP post request, we will create a new product onto our product dynamo
DB table.
To do that, I'm going to send the post request with this URL.
And in here you can see that in the body section we provide this product JSON object.
It is including the name, description, image file category and price.
So if you look at the body JSON object, we don't send ID attribute for our product table on Dynamo
DB are wrong.
The function code should be generate naive ID with using the UUID library and create a new product item
into our product table.
If you check our create product method, go to method and you can see that the product ID will be generated
into the method.
So that's why we don't send any ID information and the other attributes will be saved on table, which
is the product table and the ID is partition key and we have to send ID information and this will be
handled in the create product method.
Okay.
Very good.
So let me click the send button and perform the HTTP post operation.
See that we have successfully finished this operation and this is the body information we including
other details.
Now we have one product on product table to check this operation.
Please open the A management console and go to Dynamo DB table and I'm going to check product table.
Explore items and run this command.
See that we have created an item on the product table and the ID is generated from our Node.js Lambda
Function code and we have successfully insert a new item into product table with using lambda function
and triggering from the API gateway.
So if we check the cloud looks to understand which methods are triggered.
If you go to product function and go to monitor and we've given cloud which looks we will see the logs
that we trigger for the get and post operation.
If you open the latest log stream, you can see that in the last request comes for the post product
operation and if you scroll down you can see the whole body including in here.
So and if you scroll down you can see that for that action we are triggering to create product method.
And these are the other details which is the response.
So if you scroll up before we are creating any product, we are running to get all product which sending
the HTTP, get to the only product resources and we can verify that it is going to get all products.
Okay.
Now if you come back to our postman collection, we can continue to our test with creating a new item
which is the product to in here.
As you can see that we are creating an inserting any item, any form in our product table.
Click the send button to verify the HTTP post operation we have successfully sent to finish operation.
Now we have two items in our product table to verify that we can run the get all products methods again.
Come here and click the send button.
This time we will have two products in our product table.
As you can see, that two JSON response is coming, this HTTP get method so we can get the ID informations
in here.
For example, I'm going to get these ID information and run the get product by ID.
If you come to this get product by ID, the only thing we should change is the ID information.
At the end of the URL, we can put Slash and the ID information that we get from the HTP certificate
operation save this file and click the HTP sign method.
And we have verified that we successfully run get product by ID with specifying ID and get all the tests
in the body information of the response.
Okay, very good.
Now we can test the update function with the put command again.
I have an id and put command is also running product by ID.
We can specify the id information in here.
Say this file, but this time we can also buddy and the Jason definition, which will be which attributes
we are going to update with this update operation.
As you can see that I would like to update the name of the phone and if you click this product, buy
ID now the name is the iPhone X and in the put operation we are going to update with our iPhone X and
Y.
So let's again, I can add the updated.
In here, save this request and click the HTTP send request.
So we have successfully performed the put operation to verify that.
Go back to product, buy ID and please check this name and click to send again.
And this time name information updated successfully with the product by ID and sending the HTTP operation.
And lastly, I'm going to delete this product if you come here and provide the ID in the URL and save
this file and send the HTTP delete method, it is also successfully finished the delete operation if
you come back to get product ID and send again.
This time we don't have any product with these ID.
You can verify that we have two items and if we send again with running the second command, we have
only one item.
So that means we have successfully delete operation.
So as you can see that we have finished all CRUD operations on the product microservices bit following
the API gateway, lambda function and dynamic DB.
In the next video we will clear our resources.