Go to the API Gateway Console, by searching for the API Gateway service inside of the AWS Management Console.
Notice an API has been deployed from the script you previously ran. Click on the name of the API and you’ll see
various resources (API routes) and methods (e.g. POST, GET, PUT, DELETE). Notice that each of them is
associated with its own Lambda function. This approach allows you to scale each Lambda independently without
affecting the experience of other Lambda functions.
Let’s take a closer look at the POST /product method by clicking into it, then click Integration Request:
You can see that the Integration type of this method is Lambda, and the specific Lambda Function is
specified.
Note down the Lambda function’s name, head over to the Lambda Console (search for “Lambda” inside the AWS Management
Console search bar) and click into the Lambda function to view its definition.
Scroll down to Runtime settings, and notice that the Handler refers to the create_product
function.
Inspect the source code. Scroll down to line 48 to the create_product definition and examine the code.
Let’s examine the Fauna dashboard. On the left-hand navigator, notice that 2 collections, order
and product were created for us by the deployment script.
The syntax for creating a product document is product.create({data}). To see this in action, copy the query from the Lambda of step 7 above (lines 59-76), and insert actual values in place of the string interpolation expressions, e.g.
product.create({
'sku': 'test-123',
'name': 'Bananas',
'description': '1 bunch. Priced per banana',
'price': 0.39,
'quantity': 100,
'backorderedLimit': 10,
'backordered': false
}) {
id,
sku,
name,
description,
price,
quantity,
backorderedLimit,
backordered
}
Paste it into the Fauna web shell, and click Run:
Thus far, we’ve given you a high-level idea of the moving parts of the serverless application, a taste of the Fauna query language, and some familiarity with the AWS and Fauna web interface. To get a sense of completeness, head back to the API Gateway Console and examine the other methods, (e.g. GET /products, DELETE /product, PUT /product, GET /orders, etc), their corresponding Lambdas, the Python implementations of the functions, and the Fauna queries contained within each of them.
Now let’s head over to the next section to explore the web app included in this Lab.