3

当我遇到以下错误时,我试图使用 serverless.yml 创建 24 个 DynamoDB 表。我该如何规避这个?

Serverless: Checking Stack update progress…
.................................................................Serverless: Deployment failed!

Serverless Error ---------------------------------------

 An error occurred while provisioning your stack: TestUserTable
 - Subscriber limit exceeded: Only 10 tables can be created,
 updated, or deleted simultaneously.
Your Environment Information -----------------------------
OS: linux
Node Version: 6.6.0
Serverless Version: 1.1.0

这似乎是 Cloudformation 的一个普遍问题,这是 AWS 论坛中的一种解决方法:https ://forums.aws.amazon.com/thread.jspa?threadID=167996

我尝试添加dependson,但仍然无法解决问题。

我收到以下错误

ServerlessError: Template format error: Unresolved resource dependencies [Dev1ProductTables] in the Resources block of the template

加上DependsOn: "DevPolicyTable"引号也没有任何区别

resources:
  Resources:
    DevUserTable: 
      Type: "AWS::DynamoDB::Table"
      DependsOn: DevPolicyTable
      Properties:
        AttributeDefinitions: 
          - AttributeName: "id"
            AttributeType: "S"
        KeySchema: 
          - AttributeName: "id"
            KeyType: "HASH"
        ProvisionedThroughput: 
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        TableName: "b1-dev-user"
      DevPolicyTable: 
        Type: "AWS::DynamoDB::Table"
        DependsOn: DevClaimTable
        Properties: 
          AttributeDefinitions: 
            - AttributeName: "id"
              AttributeType: "S"
          KeySchema: 
          - AttributeName: "id"
          KeyType: "HASH"
          ProvisionedThroughput: 
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
          TableName: "b1-dev-policy"
4

1 回答 1

1

您超过了并行创建的表数量,修复它的最简单方法是使用 DependsOn。您可以将表依赖项设置到另一个表中,以便在创建依赖表之前不会创建此表。

在此示例中,在表 2 已经创建之前不会创建表 1,因此它们不会并行创建。

"Table1": {
      "Type": "AWS::DynamoDB::Table",
      "DependsOn": [
        "Table2"
      ],
      "Properties": {
        "AttributeDefinitions": [
          {
            "AttributeName": "key",
            "AttributeType": "S"
          }
        ],
        "KeySchema": [
          {
            "AttributeName": "key",
            "KeyType": "HASH"
          }
        ],
        "ProvisionedThroughput": {
          "ReadCapacityUnits": "2",
          "WriteCapacityUnits": "2"
        },
        "TableName": {
          "table1"
        }
      }, 
"Table2": {
      "Type": "AWS::DynamoDB::Table",
      "Properties": {
        "AttributeDefinitions": [
          {
            "AttributeName": "key",
            "AttributeType": "S"
          }
        ],
        "KeySchema": [
          {
            "AttributeName": "key",
            "KeyType": "HASH"
          }
        ],
        "ProvisionedThroughput": {
          "ReadCapacityUnits": "2",
          "WriteCapacityUnits": "2"
        },
        "TableName": {
          "table2"
        }
      }
于 2018-08-07T13:51:31.350 回答