aws云服务器怎么使用_使用AWS构建无服务器后端

aws云服务器怎么使用

Contrary to its name, serverless architecture does have servers. However, developers do not need to know anything about them — managing and provisioning servers are the responsibilities of the serverless platform host (in this case, AWS). Developers only need to handle writing code and building their application. Another benefit of serverless is that developers will only be charged for the resources they use.

与它的名字相反,无服务器架构确实具有服务器。 但是,开发人员无需了解任何信息-管理和配置服务器是无服务器平台主机(在本例中为AWS)的职责。 开发人员只需要处理编写代码和构建他们的应用程序。 无服务器的另一个好处是,开发人员将只为他们使用的资源付费。

In this article, we will be using the following three services from AWS to implement a serverless back-end: Amazon API Gateway, AWS Lambda, and Amazon DynamoDB.

在本文中,我们将使用AWS的以下三种服务来实现无服务器后端: Amazon API GatewayAWS LambdaAmazon DynamoDB

When a client makes a HTTP request to a public API endpoint provided by API Gateway, a Lambda function will be invoked. The Lambda function manipulates the database provided by DynamoDB and then sends the response back to the client.

当客户端向API网关提供的公共API端点发出HTTP请求时,将调用Lambda函数。 Lambda函数处理DynamoDB提供的数据库,然后将响应发送回客户端。

Want to read this story later? Save it in Journal.

想稍后再读这个故事吗? 将其保存在 日记本中

先决条件 (Prerequisites)

  • AWS account with IAM (Identity and Access Management) user set up

    设置了具有IAM(身份和访问管理)用户的AWS账户
  • Node.js

    Node.js

We’ll be building a back-end that will handle requests from the client to get information from a database of ramen restaurants in New York City.

我们将构建一个后端,该后端将处理来自客户端的请求,以从纽约市的拉面餐厅数据库中获取信息。

We will write a Lambda function that will be invoked every time a user requests a restaurant. The function will get the restaurant from the DynamoDB table and respond to the front-end of the application with the details of the specified restaurant. The Lambda function will be invoked from the browser via API Gateway.

我们将编写一个Lambda函数,该函数将在每次用户请求餐馆时调用。 该功能将从DynamoDB表获取餐厅,并使用指定餐厅的详细信息响应应用程序的前端。 Lambda函数将通过API网关从浏览器中调用。

创建DynamoDB表 (Creating a DynamoDB Table)

Before we can implement the Lambda function, we will need to create a table in DynamoDB. In your AWS console, navigate to DynamoDB and click the Create table button to begin.

在实现Lambda函数之前,我们需要在DynamoDB中创建一个表。 在您的AWS控制台中,导航到DynamoDB并单击Create table按钮开始。

1. Let’s name the table “RamenRestaurants”.

1.让我们将表命名为“ RamenRestaurants ”。

2. Give the table a primary key (or partition key) of “RestaurantId” with a type of “String”. The primary key is a unique identifier for each item in the table. It is used for querying and accessing the data in the table. We will be querying the table via the RestaurantId later on when we write the lambda function.

2.为表赋予主键(或分区键)“ RestaurantId ”,类型为“字符串”。 主键是表中每个项目的唯一标识符。 它用于查询和访问表中的数据。 我们稍后将在编写lambda函数时通过RestaurantId查询表。

3. Use default settings should already be checked off by default.

3. 默认情况下,应已选中“ 使用默认设置”

4. Hit Create.

4.点击创建

Image for post

5. Congrats! You’ve just created your first DynamoDB table. The next screen will show you an overview of your new table.

5.恭喜! 您刚刚创建了第一个DynamoDB表。 下一个屏幕将向您显示新表的概述。

6. To add items to your new table, click on the Items tab and then hit the Create item button. Provide ‘1’ as the RestaurantId. To add attributes to the item, hit the ‘+’ button and choose Append and choose a type accordingly. I am adding the following attributes and information as my first item but feel free to create yours however you’d like.

6.要将项目添加到新表中,请单击“ 项目”选项卡,然后单击“ 创建项目”按钮。 提供“ 1”作为RestaurantId。 要将属性添加到项目,请点击

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值