You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/serverless-framework-aws-s3/_index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Deploy a static website to Amazon S3 and integrate with AWS Lambda and DynamoDB using the Serverless Framework
3
3
4
-
minutes_to_complete: 30
4
+
minutes_to_complete: 60
5
5
6
6
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.
7
7
@@ -12,7 +12,7 @@ learning_objectives:
12
12
prerequisites:
13
13
- 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/).
14
14
- 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/).
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/serverless-framework-aws-s3/configuration.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,31 +8,31 @@ layout: learningpathall
8
8
9
9
### Service Declaration
10
10
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 randomlygenerated 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.
15
15
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.
17
17
18
18
You will also add JavaScript code that reads the API endpoints of the two AWS Lambda functions and dynamically updates the static website.
19
19
20
20
### 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:
22
22
23
23
```console
24
24
serverless
25
25
```
26
26
27
27
In the wizard that appears, proceed as follows:
28
28
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**.
32
32
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.
36
36
37
37
### serverless.yml
38
38
To define the AWS resources, open `serverless.yml` and modify it as follows:
@@ -168,12 +168,12 @@ package:
168
168
exclude:
169
169
- node_modules/**
170
170
```
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:
172
172
* `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.
174
174
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).
177
177
* `WebsiteConfiguration` - configures the S3 bucket to host a static website, specifying `index.html` as the main page and error.html as the error page.
178
178
* `OwnershipControls` - ensures that the bucket enforces ownership for all objects.
179
179
* `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
182
182
These settings are required to make the website publicly available.
183
183
184
184
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.
186
186
* `WebsiteURL` - generates the URL for the S3-hosted static website.
187
187
188
188
In the Plugins section, you define:
189
189
* `serverless-s3-sync` - syncs local files from the website directory to the specified S3 bucket during deployment.
190
190
* `serverless-plugin-scripts` - allows custom scripts to be run before deployment.
191
191
192
192
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.
195
195
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.
197
197
198
198
### handler.js
199
199
You will now implement the two AWS Lambda functions. Open the file `handler.js`, and replace its contents with the following code:
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/serverless-framework-aws-s3/deployment.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,17 +5,19 @@ weight: 5
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
7
7
---
8
-
In this section you will deploy the resources you declared in the previous section.
8
+
9
9
10
10
### Deployment
11
+
In this section you will deploy the resources you declared in the previous section.
12
+
11
13
To deploy the resources, open the terminal or command prompt and navigate to `AwsServerlessDynamoDbLambda` folder. Then invoke the following commands:
12
14
13
15
```console
14
16
npm install --save-dev
15
17
serverless deploy
16
18
```
17
19
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:
19
21
20
22
```output
21
23
Deploying "AwsServerlessDynamoDbLambdaS3" to stage "dev" (us-east-1)
@@ -44,7 +46,7 @@ Wait for the deployment to complete, and then type:
44
46
serverless info --verbose
45
47
```
46
48
47
-
This command will generate the following output:
49
+
This command generates the following output:
48
50
```output
49
51
service: AwsServerlessDynamoDbLambdaS3
50
52
stage: dev
@@ -70,7 +72,7 @@ Use the `WebsiteURL` to open your website:
70
72
71
73

72
74
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.
74
76
75
77
To clean up the resources you created, you can use a single command:
76
78
@@ -81,7 +83,7 @@ serverless remove
81
83
### Summary
82
84
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.
83
85
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.
85
87
86
88
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.
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/serverless-framework-aws-s3/objective.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,13 @@ layout: learningpathall
7
7
---
8
8
### What is the Serverless Framework?
9
9
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.
11
11
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:
13
13
1.[Use Amazon DynamoDB for your IoT applications running on Arm64](/learning-paths/laptops-and-desktops/win_aws_iot_dynamodb).
14
14
2.[Use AWS Lambda for IoT applications running on Arm64](/learning-paths/laptops-and-desktops/win_aws_iot_lambda).
15
15
3.[Integrate AWS Lambda with DynamoDB for IoT applications running on Windows on Arm](/learning-paths/laptops-and-desktops/win_aws_iot_lambda_dynamodb).
16
16
17
17
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.
18
18
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