Skip to content

Commit fe1ed5d

Browse files
Merge pull request #1261 from madeline-underwood/Serverless_framework
Serverless framework_KB to review
2 parents 3a2d8f6 + d6ad2f0 commit fe1ed5d

File tree

6 files changed

+50
-48
lines changed

6 files changed

+50
-48
lines changed

content/learning-paths/servers-and-cloud-computing/serverless-framework-aws-s3/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Deploy a static website to Amazon S3 and integrate with AWS Lambda and DynamoDB using the Serverless Framework
33

4-
minutes_to_complete: 30
4+
minutes_to_complete: 60
55

66
who_is_this_for: This learning path is for software developers interested in learning how to deploy serverless applications using the Serverless Framework and Amazon Web Services.
77

@@ -12,7 +12,7 @@ learning_objectives:
1212
prerequisites:
1313
- A Windows on Arm computer such as [Windows Dev Kit 2023](https://learn.microsoft.com/en-us/windows/arm/dev-kit), a Lenovo Thinkpad X13s running Windows 11, or a Windows on Arm [virtual machine](/learning-paths/cross-platform/woa_azure/).
1414
- Any code editor. [Visual Studio Code for Arm64](https://code.visualstudio.com/docs/?dv=win32arm64user) is suitable.
15-
- Completion of this [Learning Path](/learning-paths/servers-and-cloud-computing/serverless-framework-aws-intro/).
15+
- Completion of the Learning Path that shows you how to [Deploy AWS services using the Serverless Framework](/learning-paths/servers-and-cloud-computing/serverless-framework-aws-intro/).
1616

1717
author_primary: Dawid Borycki
1818

content/learning-paths/servers-and-cloud-computing/serverless-framework-aws-s3/_review.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ review:
3232
- To compile all source files before deploying them to AWS.
3333
- To dynamically update the index.js file with actual API endpoint URLs before deployment.
3434
- To create a backup of all project files before starting the deployment process.
35-
- To validate the serverless.yml file for syntax errors..
35+
- To validate the serverless.yml file for syntax errors.
3636

3737
correct_answer: 2
3838
explanation: >
39-
We used custom prepare.js file to implement the script, which dynamically updated the index.js file with actual API endpoint URLs before deployment.
39+
You used custom prepare.js file to implement the script, which dynamically updated the index.js file with actual API endpoint URLs before deployment.
4040
4141
4242
# ================================================================================

content/learning-paths/servers-and-cloud-computing/serverless-framework-aws-s3/configuration.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ layout: learningpathall
88

99
### Service Declaration
1010
In this section, you will declare a serverless service composed of the following AWS resources:
11-
1. DynamoDB Table - This will store hypothetical sensor data, including timestamps and randomly generated temperatures.
12-
2. Two AWS Lambda Functions - The first function will write temperatures to the DynamoDB table, and the second will retrieve the average temperature value.
13-
3. IAM Role - A set of permissions that enable the AWS Lambda functions to write to and read data from the DynamoDB table.
14-
4. S3 Bucket - A bucket to host the static website.
11+
* DynamoDB Table - this stores hypothetical sensor data, including timestamps and randomly-generated temperatures.
12+
* Two AWS Lambda Functions - the first function writes temperatures to the DynamoDB table, and the second retrieves the average temperature value.
13+
* IAM Role - a set of permissions that enable the AWS Lambda functions to write to and read data from the DynamoDB table.
14+
* S3 Bucket - a bucket that hosts the static website.
1515

16-
Additionally, the service will use the Serverless S3 Sync plugin to deploy the static website to the S3 bucket. The website will contain two buttons and a text box: the buttons will allow the user to invoke the Lambda functions, and the text box will display the average temperature stored in the DynamoDB table.
16+
Additionally, the service uses the Serverless S3 Sync plugin to deploy the static website to the S3 bucket. The website contains two buttons and a text box: the buttons allow the user to invoke the Lambda functions, and the text box displays the average temperature stored in the DynamoDB table.
1717

1818
You will also add JavaScript code that reads the API endpoints of the two AWS Lambda functions and dynamically updates the static website.
1919

2020
### Declare a service
21-
To create a new serverless service, open the command prompt or terminal and type the following:
21+
To create a new serverless service, open the command prompt or terminal and enter the following:
2222

2323
```console
2424
serverless
2525
```
2626

2727
In the wizard that appears, proceed as follows:
2828
1. Select the **AWS / Node.js / Simple Function** template.
29-
2. In the *Name Your Project field*, type **AwsServerlessDynamoDbLambdaS3**.
30-
3. In the *Please login/register* or enter your license key section, select **Login/Register** and sign in to the Serverless Framework.
31-
4. In the *Create Or Select An Existing App section*, select **Skip Adding An App**.
29+
2. In the *Name Your Project* field, type **AwsServerlessDynamoDbLambdaS3**.
30+
3. In the *Please login/register* or *enter your license key* section, select **Login/Register** and sign in to the Serverless Framework.
31+
4. In the *Create Or Select An Existing App* section, select **Skip Adding An App**.
3232

33-
The tool will generate the project composed of the following files:
34-
1. `serverless.yml` - this contains the declaration of the infrastructure and services for a serverless application.
35-
2. `handler.js` - you use this file to implement the core functionality of your serverless application, handling business logic and interactions with other services. Here, you will use this file to implement Lambda functions.
33+
The tool generates the project composed of the following files:
34+
* `serverless.yml` - this contains the declaration of the infrastructure and services for a serverless application.
35+
* `handler.js` - you use this file to implement the core functionality of your serverless application, handling business logic and interactions with other services. Here, you will use this file to implement Lambda functions.
3636

3737
### serverless.yml
3838
To define the AWS resources, open `serverless.yml` and modify it as follows:
@@ -168,12 +168,12 @@ package:
168168
exclude:
169169
- node_modules/**
170170
```
171-
The declaration above builds upon the configuration you created earlier in this [Learning Path](/learning-paths/servers-and-cloud-computing/serverless-framework-aws-lambda-dynamodb/). Specifically, it includes a declaration for a DynamoDB table, an IAM role, and two Lambda functions:
171+
This declaration builds upon the configuration you created in the Learning Path entitled [Deploy and integrate AWS Lambda with DynamoDB using the Serverless Framework](/learning-paths/servers-and-cloud-computing/serverless-framework-aws-lambda-dynamodb/). Specifically, it includes a declaration for a DynamoDB table, an IAM role, and two Lambda functions:
172172
* `writeTemperatures` - its handler is set to handler.writeTemperatures. This function is triggered through an HTTP POST event.
173-
* `getAverageTemperature` -its handler is set to handler.getAverageTemperature. This function is triggered through an HTTP GET event.
173+
* `getAverageTemperature` - its handler is set to handler.getAverageTemperature. This function is triggered through an HTTP GET event.
174174

175-
There are a few new additions. Under the Resources section, you have the S3 Bucket configuration, which specifies the following:
176-
* WebsiteBucket - creates an S3 bucket named `iot-temperature-service-${self:provider.stage}-website`, where `${self:provider.stage}` dynamically inserts the deployment stage (e.g., dev, prod).
175+
There are a few new additions. Under the *Resources* section, you have the S3 Bucket configuration, which specifies the following:
176+
* `WebsiteBucket` - creates an S3 bucket named `iot-temperature-service-${self:provider.stage}-website`, where `${self:provider.stage}` dynamically inserts the deployment stage (for example, dev, prod).
177177
* `WebsiteConfiguration` - configures the S3 bucket to host a static website, specifying `index.html` as the main page and error.html as the error page.
178178
* `OwnershipControls` - ensures that the bucket enforces ownership for all objects.
179179
* `PublicAccessBlockConfiguration` - disables public access block settings, allowing the bucket to serve content publicly.
@@ -182,18 +182,18 @@ There are a few new additions. Under the Resources section, you have the S3 Buck
182182
These settings are required to make the website publicly available.
183183

184184
Next, you define outputs for the Serverless deployment:
185-
* `WriteTemperaturesEndpoint` and `GetAverageTemperatureEndpoint` - provide the full URLs of the API Gateway endpoints for the two AWS Lambda functions.
185+
* `WriteTemperaturesEndpoint` and `GetAverageTemperatureEndpoint` - these provide the full URLs of the API Gateway endpoints for the two AWS Lambda functions.
186186
* `WebsiteURL` - generates the URL for the S3-hosted static website.
187187

188188
In the Plugins section, you define:
189189
* `serverless-s3-sync` - syncs local files from the website directory to the specified S3 bucket during deployment.
190190
* `serverless-plugin-scripts` - allows custom scripts to be run before deployment.
191191

192192
Then, you specify custom settings for the plugins:
193-
* `custom`: Defines custom settings for the S3 sync plugin.
194-
* `s3Sync`: Specifies the local directory (website) to be synced to the S3 bucket.
193+
* `custom`: defines custom settings for the S3 sync plugin.
194+
* `s3Sync`: specifies the local directory (website) to be synced to the S3 bucket.
195195

196-
Lastly, you will exclude the `node_modules` directory from the deployment package using `package.exclude` to reduce the package size.
196+
Lastly, you exclude the `node_modules` directory from the deployment package using `package.exclude` to reduce the package size.
197197

198198
### handler.js
199199
You will now implement the two AWS Lambda functions. Open the file `handler.js`, and replace its contents with the following code:

content/learning-paths/servers-and-cloud-computing/serverless-framework-aws-s3/deployment.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ weight: 5
55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
8-
In this section you will deploy the resources you declared in the previous section.
8+
99

1010
### Deployment
11+
In this section you will deploy the resources you declared in the previous section.
12+
1113
To deploy the resources, open the terminal or command prompt and navigate to `AwsServerlessDynamoDbLambda` folder. Then invoke the following commands:
1214

1315
```console
1416
npm install --save-dev
1517
serverless deploy
1618
```
1719

18-
The first command will save required dependencies declared in `project.json`. The second command will deploy the AWS resources. After the deployment you will see the following output:
20+
The first command saves the required dependencies declared in `project.json`. The second command deploys the AWS resources. After the deployment, you will see the following output:
1921

2022
```output
2123
Deploying "AwsServerlessDynamoDbLambdaS3" to stage "dev" (us-east-1)
@@ -44,7 +46,7 @@ Wait for the deployment to complete, and then type:
4446
serverless info --verbose
4547
```
4648

47-
This command will generate the following output:
49+
This command generates the following output:
4850
```output
4951
service: AwsServerlessDynamoDbLambdaS3
5052
stage: dev
@@ -70,7 +72,7 @@ Use the `WebsiteURL` to open your website:
7072

7173
![fig1](figures/01.png)
7274

73-
Click the Write Temperatures button to invoke the Lambda function that writes records to the DynamoDB. Then click the Get Average Temperature button to retrieve the average value. It will be displayed in the page.
75+
Click the **Write Temperatures** button to invoke the Lambda function that writes records to the DynamoDB. Then click the **Get Average Temperature** button to retrieve the average value. It is displayed on the page.
7476

7577
To clean up the resources you created, you can use a single command:
7678

@@ -81,7 +83,7 @@ serverless remove
8183
### Summary
8284
In this Learning Path, you built a serverless solution that integrates AWS Lambda, DynamoDB, and S3 to create a scalable, cloud-based application with minimal operational overhead. Specifically, you configured and deployed essential AWS resources, including a DynamoDB table to store temperature data, two Lambda functions to manage this data (writing temperatures and calculating the average), and an S3 bucket to host a static website.
8385

84-
The Serverless Framework allowed you to automate the deployment and management of these AWS resources, reducing manual setup and ensuring consistent infrastructure as code. Using custom scripts, you dynamically updated the index.js file on the website with the actual API endpoints generated during deployment, ensuring seamless integration between the front-end and back-end services.
86+
The Serverless Framework allowed you to automate the deployment and management of these AWS resources, reducing manual setup and ensuring consistent infrastructure as code. Using custom scripts, you dynamically updated the index.js file on the website with the API endpoints generated during deployment, ensuring seamless integration between the frontend and backend services.
8587

8688
The S3 bucket was configured to host a static website, providing a user interface that allows interaction with the deployed Lambda functions through a web page.
8789

content/learning-paths/servers-and-cloud-computing/serverless-framework-aws-s3/objective.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ layout: learningpathall
77
---
88
### What is the Serverless Framework?
99

10-
The Serverless Framework is an open-source toolkit that empowers developers to build and deploy applications on cloud platforms without the need to manage server operations. By handling the underlying server infrastructure, it allows developers to concentrate on coding and feature development, boosting productivity and efficiency. The framework is compatible with multiple cloud providers, including AWS, Google Cloud, and Microsoft Azure, offering a flexible and scalable solution for contemporary application development. With its robust plug-ins and strong community support, the Serverless Framework streamlines complex deployment workflows, encourages best practices, and supports rapid iteration, making it a vital tool in the DevOps ecosystem.
10+
The Serverless Framework is an open-source toolkit that empowers developers to build and deploy applications on cloud platforms without the need to manage server operations. By handling the underlying server infrastructure, it allows developers to focus on coding and feature development, boosting productivity and efficiency. The framework is compatible with multiple cloud providers, including AWS, Google Cloud, and Microsoft Azure, offering a flexible and scalable solution for contemporary application development. With its robust plug-ins and strong community support, the Serverless Framework streamlines complex deployment workflows, encourages best practices, and supports rapid iteration, making it a vital tool in the DevOps ecosystem.
1111

12-
In the previous [Learning Path](/learning-paths/servers-and-cloud-computing/serverless-framework-aws-lambda-dynamodb/), you learned how to set up the Serverless Framework for AWS and to deploy two AWS Lambda functions that consume data from DynamoDB. For more tutorials about running IoT applications by manually creating various AWS resources, please review the following learning paths:
12+
In the previous [Learning Path](/learning-paths/servers-and-cloud-computing/serverless-framework-aws-lambda-dynamodb/), you learned how to set up the Serverless Framework for AWS and how to deploy two AWS Lambda functions that consume data from DynamoDB. For more tutorials about running IoT applications by manually creating various AWS resources, please review the following learning paths:
1313
1. [Use Amazon DynamoDB for your IoT applications running on Arm64](/learning-paths/laptops-and-desktops/win_aws_iot_dynamodb).
1414
2. [Use AWS Lambda for IoT applications running on Arm64](/learning-paths/laptops-and-desktops/win_aws_iot_lambda).
1515
3. [Integrate AWS Lambda with DynamoDB for IoT applications running on Windows on Arm](/learning-paths/laptops-and-desktops/win_aws_iot_lambda_dynamodb).
1616

1717
Although manual resource provisioning has certain advantages, it can become increasingly challenging as you deploy applications to the cloud. As your solutions expand and grow in complexity, the difficulties of manual provisioning multiply. This is where the Serverless Framework becomes valuable, providing a streamlined and efficient method for managing cloud resources.
1818

19-
In this learning path, you will learn how to extend the previous example through a website that interacts with AWS Lambda functions and deploy it to an S3 bucket using the Serverless Framework. This is similar to what you learned in this [Learning Path](/learning-paths/laptops-and-desktops/win_aws_iot_s3).
19+
In this Learning Path, you will learn how to extend the previous example through a website that interacts with AWS Lambda functions and deploy it to an S3 bucket using the Serverless Framework. This is similar to the content covered in the Learning Path about using [Amazon S3 for your IoT applications running Windows on Arm](/learning-paths/laptops-and-desktops/win_aws_iot_s3).

0 commit comments

Comments
 (0)