Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 6dd66be

Browse files
committed
update WebApp step 3 README for format similar to steps 1 and 2
1 parent 4cf13d0 commit 6dd66be

File tree

1 file changed

+41
-71
lines changed

1 file changed

+41
-71
lines changed
Lines changed: 41 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,34 @@
11
# Module 3: Serverless Service Backend
22

3-
In this module you'll use AWS Lambda and Amazon DynamoDB to build a backend process for handling requests from your web application. The browser application that you deployed in the first module allows users to request that a unicorn be sent to a location of their choice. In order to fulfill those requests, the JavaScript running in the browser will need to invoke a service running in the cloud.
3+
In this module you'll use [AWS Lambda][lambda] and [Amazon DynamoDB][dynamodb] to build a backend process for handling requests from your web application. The browser application that you deployed in the first module allows users to request that a unicorn be sent to a location of their choice. In order to fulfill those requests, the JavaScript running in the browser will need to invoke a service running in the cloud.
44

55
You'll implement a Lambda function that will be invoked each time a user requests a unicorn. The function will select a unicorn from the fleet, record the request in a DynamoDB table and then respond to the front-end application with details about the unicorn being dispatched.
66

77
![Serverless backend architecture](../images/serverless-backend-architecture.png)
88

9-
The function is invoked from the browser using Amazon API Gateway. You'll implement that connection in the next module. For this module you'll just test your function in isolation.
10-
11-
If you want to skip ahead to the next module, you can **launch the stack from [module 4 (RESTful APIs)](../4_RESTfulAPIs)**.
9+
The function is invoked from the browser using [Amazon API Gateway][api-gw]. You'll implement that connection in the next module. For this module you'll just test your function in isolation.
1210

1311
## Implementation Instructions
1412

15-
Each of the following sections provide an implementation overview and detailed, step-by-step instructions. The overview should provide enough context for you to complete the implementation if you're already familiar with the AWS Management Console or you want to explore the services yourself without following a walkthrough.
13+
:heavy_exclamation_mark: Ensure you've completed the [User Management][user-management] step before beginning this module.
1614

17-
If you're using the latest version of the Chrome, Firefox, or Safari web browsers the step-by-step instructions won't be visible until you expand the section.
15+
Each of the following sections provides an implementation overview and detailed, step-by-step instructions. The overview should provide enough context for you to complete the implementation if you're already familiar with the AWS Management Console or you want to explore the services yourself without following a walkthrough.
1816

1917
### 1. Create an Amazon DynamoDB Table
2018

2119
Use the Amazon DynamoDB console to create a new DynamoDB table. Call your table `Rides` and give it a partition key called `RideId` with type String. The table name and partition key are case sensitive. Make sure you use the exact IDs provided. Use the defaults for all other settings.
2220

2321
After you've created the table, note the ARN for use in the next step.
2422

25-
<details>
26-
<summary><strong>Step-by-step instructions (expand for details)</strong></summary><p>
27-
28-
1. From the AWS Management Console, choose **Services** then select **DynamoDB** under Databases.
29-
23+
**:white_check_mark: Step-by-step directions**
24+
1. Go to the [Amazon DynamoDB Console][dynamodb-console]
3025
1. Choose **Create table**.
31-
3226
1. Enter `Rides` for the **Table name**. This field is case sensitive.
33-
3427
1. Enter `RideId` for the **Partition key** and select **String** for the key type. This field is case sensitive.
35-
3628
1. Check the **Use default settings** box and choose **Create**.
37-
3829
![Create table screenshot](../images/ddb-create-table.png)
39-
4030
1. Scroll to the bottom of the Overview section of your new table and note the **ARN**. You will use this in the next section.
4131

42-
</p></details>
43-
44-
4532
### 2. Create an IAM Role for Your Lambda function
4633

4734
#### Background
@@ -54,52 +41,35 @@ Use the IAM console to create a new role. Name it `WildRydesLambda` and select A
5441

5542
Attach the managed policy called `AWSLambdaBasicExecutionRole` to this role to grant the necessary CloudWatch Logs permissions. Also, create a custom inline policy for your role that allows the `ddb:PutItem` action for the table you created in the previous section.
5643

57-
<details>
58-
<summary><strong>Step-by-step instructions (expand for details)</strong></summary><p>
59-
60-
1. From the AWS Management Console, click on **Services** and then select **IAM** in the Security, Identity & Compliance section.
61-
62-
1. Select **Roles** in the left navigation bar and then choose **Create new role**.
63-
44+
**:white_check_mark: Step-by-step directions**
45+
1. Go to the [AWS IAM Console][iam-console]
46+
1. Select **Roles** in the left navigation bar and then choose **Create role**.
6447
1. Select **Lambda** for the role type from the **AWS service** group, then click **Next: Permissions**
65-
6648
**Note:** Selecting a role type automatically creates a trust policy for your role that allows AWS services to assume this role on your behalf. If you were creating this role using the CLI, AWS CloudFormation or another mechanism, you would specify a trust policy directly.
67-
6849
1. Begin typing `AWSLambdaBasicExecutionRole` in the **Filter** text box and check the box next to that role.
69-
50+
1. Click **Next: Tags**. Add any tags that you wish.
7051
1. Click **Next: Review**.
71-
7252
1. Enter `WildRydesLambda` for the **Role name**.
53+
1. Choose **Create role**.
7354

74-
1. Choose **Create role**.
75-
76-
1. Type `WildRydesLambda` into the filter box on the Roles page and choose the role you just created.
55+
Next you need to add permissions to the role so that it can access your DynamoDB table.
7756

57+
**:white_check_mark: Step-by-step directions*
58+
1. While in the IAM Console on the roles page type `WildRydesLambda` into the filter box on the Roles page and choose the role you just created.
7859
1. On the Permissions tab, choose the **Add inline policy** link in the lower right corner to create a new inline policy.
7960
![Inline policies screenshot](../images/inline-policies.png)
80-
8161
1. Select **Choose a service**.
82-
8362
1. Begin typing `DynamoDB` into the search box labeled **Find a service** and select **DynamoDB** when it appears.
8463
![Select policy service](../images/select-policy-service.png)
85-
8664
1. Choose **Select actions**.
87-
8865
1. Begin typing `PutItem` into the search box labeled **Filter actions** and check the box next to **PutItem** when it appears.
89-
9066
1. Select the **Resources** section.
91-
9267
1. With the **Specific** option selected, choose the Add ARN link in the **table** section.
93-
9468
1. Paste the ARN of the table you created in the previous section in the **Specify ARN for table** field, and choose **Add**.
95-
9669
1. Choose **Review Policy**.
97-
9870
1. Enter `DynamoDBWriteAccess` for the policy name and choose **Create policy**.
9971
![Review Policy](../images/review-policy.png)
10072

101-
</p></details>
102-
10373
### 3. Create a Lambda Function for Handling Requests
10474

10575
#### Background
@@ -112,46 +82,31 @@ Use the AWS Lambda console to create a new Lambda function called `RequestUnicor
11282

11383
Make sure to configure your function to use the `WildRydesLambda` IAM role you created in the previous section.
11484

115-
<details>
116-
<summary><strong>Step-by-step instructions (expand for details)</strong></summary><p>
117-
118-
1. Choose on **Services** then select **Lambda** in the Compute section.
119-
85+
**:white_check_mark: Step-by-step directions**
86+
1. Go to the [AWS Lambda][lambda-console]
12087
1. Click **Create function**.
121-
12288
1. Keep the default **Author from scratch** card selected.
123-
12489
1. Enter `RequestUnicorn` in the **Name** field.
125-
126-
1. Select **Node.js 6.10** for the **Runtime**.
127-
90+
1. Select **Node.js 8.10** for the **Runtime**.
91+
2. Expand *Choose or create an execution role* under **Permissions**.
12892
1. Ensure `Choose an existing role` is selected from the **Role** dropdown.
129-
13093
1. Select `WildRydesLambda` from the **Existing Role** dropdown.
13194
![Create Lambda function screenshot](../images/create-lambda-function.png)
132-
13395
1. Click on **Create function**.
134-
13596
1. Scroll down to the **Function code** section and replace the existing code in the **index.js** code editor with the contents of [requestUnicorn.js](requestUnicorn.js).
13697
![Create Lambda function screenshot](../images/create-lambda-function-code.png)
137-
13898
1. Click **"Save"** in the upper right corner of the page.
13999

140-
</p></details>
141-
142100
## Implementation Validation
143101

144102
For this module you will test the function that you built using the AWS Lambda console. In the next module you will add a REST API with API Gateway so you can invoke your function from the browser-based application that you deployed in the first module.
145103

146-
1. From the main edit screen for your function, select **Configure test event** from the the **Select a test event...** dropdown.
104+
**:white_check_mark: Step-by-step directions**
105+
1. From the main edit screen for your function, select **Configure test events** from the the **Select a test event...** dropdown.
147106
![Configure test event](../images/configure-test-event.png)
148-
149107
1. Keep **Create new test event** selected.
150-
151108
1. Enter `TestRequestEvent` in the **Event name** field
152-
153109
1. Copy and paste the following test event into the editor:
154-
155110
```JSON
156111
{
157112
"path": "/ride",
@@ -173,15 +128,10 @@ For this module you will test the function that you built using the AWS Lambda c
173128
"body": "{\"PickupLocation\":{\"Latitude\":47.6174755835663,\"Longitude\":-122.28837066650185}}"
174129
}
175130
```
176-
177131
![Configure test event](../images/configure-test-event-2.png)
178-
179132
1. Click **Create**.
180-
181133
1. On the main function edit screen click **Test** with `TestRequestEvent` selected in the dropdown.
182-
183134
1. Scroll to the top of the page and expand the **Details** section of the **Execution result** section.
184-
185135
1. Verify that the execution succeeded and that the function result looks like the following:
186136
```JSON
187137
{
@@ -193,4 +143,24 @@ For this module you will test the function that you built using the AWS Lambda c
193143
}
194144
```
195145

196-
After you have successfully tested your new function using the Lambda console, you can move on to the next module, [RESTful APIs](../4_RESTfulAPIs).
146+
### :star: Recap
147+
148+
:key: [AWS Lambda][lambda] is a serverless functions as a service product that removes the burden of managing servers to run your applications. You configure a trigger and set the role that the function can use and then can interface with almost anything you want from databases, to datastores, to other services eithe publicly on the internet or in your own Amazon Virtual Private Cloud (VPC). [Amazon DynamoDB][dynamodb] is a non-relational serverless database that can scale automatically to handle massive amounts of traffic and data without you need manage any servers.
149+
150+
:wrench: In this module you've created a DynamoDB table and then a Lambda function to write data into it. This function will be put behind an Amazon API Gateway in the next module which will in turn be connected to your web application to capture the ride details from your users.
151+
152+
### Next
153+
154+
:white_check_mark: After you have successfully tested your new function using the Lambda console, you can move on to the next module, [RESTful APIs][restful-apis].
155+
156+
[amplify-console]: https://aws.amazon.com/amplify/console/
157+
[cognito]: https://aws.amazon.com/cognito/
158+
[lambda]: https://aws.amazon.com/lambda/
159+
[api-gw]: https://aws.amazon.com/api-gateway/
160+
[dynamodb]: https://aws.amazon.com/dynamodb/
161+
[static-web-hosting]: ../1_StaticWebHosting/
162+
[user-management]: ../2_UserManagement/
163+
[restful-apis]: ../4_RESTfulAPIs/
164+
[dynamodb-console]: https://console.aws.amazon.com/dynamodb/home
165+
[iam-console]: https://console.aws.amazon.com/iam/home
166+
[lambda-console]: https://console.aws.amazon.com/lambda/home

0 commit comments

Comments
 (0)