最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

在serverless.yml中创建两个dynamoDB表

运维笔记admin19浏览0评论

在serverless.yml中创建两个dynamoDB表

在serverless.yml中创建两个dynamoDB表

我尝试将2个表添加到serverless.yml以与DynamoDB链接。

我在serverless.yml中的代码的一部分:

...       
 resources:
      Resources:
        ItemsTable:
          Type: "AWS::DynamoDB::Table"
          Properties:
            TableName: "InvoiceConfig"
            AttributeDefinitions:
            - AttributeName: "providerName"
              AttributeType: "S"
            KeySchema:
            - AttributeName: "providerName"
              KeyType: "HASH"
            ProvisionedThroughput:
              ReadCapacityUnits: 2
              WriteCapacityUnits: 2
            TableName: "DifferentTermsPages"
            AttributeDefinitions:
            - AttributeName: "id"
              AttributeType: "S"
            - AttributeName: "providerName"
              AttributeType: "S"
            - AttributeName: "productType"
              AttributeType: "S"
            - AttributeName: "language"
              AttributeType: "S"
            - AttributeName: "terms"
              AttributeType: "L"
            KeySchema:
            - AttributeName: "id"
              KeyType: "HASH"
            - AttributeName: "providerName"
              KeyType: "HASH"
            - AttributeName: "productType"
              KeyType: "HASH"
            - AttributeName: "language"
              KeyType: "HASH"
            - AttributeName: "terms"
              KeyType: "HASH"
            ProvisionedThroughput:
              ReadCapacityUnits: 10
              WriteCapacityUnits: 10

那是对的吗??

我的表是:

InvoiceConfig: with columns: providerName (String)
DifferentTermsPages: id (String), providerName (String), productType (String), language (String), terms (list)

我需要在serverles.yml中进行更多更改吗?表达式“ReadCapacityUnits”和“WriteCapacityUnits”的含义是什么?

回答如下:

两个资源(即两个DynamoDB表)之间应该有一些分离。

注意:-

您可以在创建DynamoDB表时仅定义关键属性。换句话说,您不需要定义所有其他非键属性。

试试这个:-

Resources:
ItemsTable:
  Type: "AWS::DynamoDB::Table"
  Properties:
    TableName: "InvoiceConfig"
    AttributeDefinitions:
    - AttributeName: "providerName"
      AttributeType: "S"
    KeySchema:
    - AttributeName: "providerName"
      KeyType: "HASH"
    ProvisionedThroughput:
      ReadCapacityUnits: 2
      WriteCapacityUnits: 2            
DifferentTermsPages:
  Type: "AWS::DynamoDB::Table"
  Properties:             
    TableName: "DifferentTermsPages"
    AttributeDefinitions:
    - AttributeName: "id"
      AttributeType: "S"
    KeySchema:
    - AttributeName: "id"
      KeyType: "HASH"
    ProvisionedThroughput:
      ReadCapacityUnits: 10
      WriteCapacityUnits: 10    

读写容量单位: -

您可以根据读取容量单位和写入容量单位指定吞吐量容量:

对于最大为4 KB的项目,一个读取容量单位表示每秒一次强烈一致的读取,或每秒两次最终一致读取。如果需要读取大于4 KB的项目,DynamoDB将需要消耗额外的读取容量单位。所需的读取容量单位总数取决于项目大小,以及是否需要最终一致或高度一致的读取。一个写入容量单位表示每秒最多1 KB的项目的一次写入。如果需要编写大于1 KB的项目,DynamoDB将需要消耗额外的写入容量单位。所需的写入容量单位总数取决于项目大小。

Read and write capacity units

发布评论

评论列表(0)

  1. 暂无评论