gpt4 book ai didi

aws-lambda - 为什么无服务器要求您对 dynamodb 设置非常具体?

转载 作者:行者123 更新时间:2023-12-01 12:15:17 25 4
gpt4 key购买 nike

发件人:https://github.com/serverless/examples/blob/master/aws-node-rest-api-with-dynamodb/serverless.yml

resources:
Resources:
TodosDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.DYNAMODB_TABLE}

难道 DynamoDB 不应该是无模式的吗?为什么要在这里完成吞吐量配置?这个配置应该提交,对吧?包括特定配置详细信息背后的想法是什么?

最佳答案

Why does serverless require you to be very specific with your dynamodb settings?

那是 AWS 的要求,而不是无服务器的要求。

resources 部分由 serverless 直接传递给 AWS CloudFormation,因此它应遵循 CloudFormation 的语法/规则。

Isn't DynamoDB supposed to be schemaless?

是的。就像 ALL 无模式数据库一样,它需要一个 key 才能工作。如果您不提供 key ,其他数据库(例如 MongoDB)只是简单地为您创建 key 。 DynamoDB 只要求您显式设置 key (以换取速度和可扩展性),但其余值都由您决定,而且它是“无模式的”。

Why is throughput provisioning done here? This config is supposed to be committed, right? What's the idea behind including specific config details?

使用 serverless.yml 文件的 resources 部分的全部意义在于通过代码管理您的基础设施。通过在代码中定义您的应用程序/Web 服务所需的基础架构,可以更轻松地创建、更新或删除这些资源。

我认为没有人会喜欢通过 AWS DynamoDB Web 控制台手动对十个不同区域中每个区域的五个 DynamoDB 表进行任何基础架构更改(例如,增加配置的吞吐量)。 :-)

But unlike other variables, throughput provisioning depends on demand and requirements can change.

当需求和要求发生变化时,您可以在 serverless.yml 中进行更改。同样,基础设施即代码的全部目的是您永远不必接触 AWS 控制台本身。

How do devs usually enter this into serverless.yml? Also, wouldn't it reset every time it deploys?

它会重置。这就是为什么您必须在 serverless.yml 而不是 AWS 控制台中进行更改。

如果您指的是具有不同需求和要求的不同环境,您可以为每个环境设置不同的值。

关于aws-lambda - 为什么无服务器要求您对 dynamodb 设置非常具体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48952567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com