使用云形成为 DynamoDB 启用 TTL

Sha*_*ler 3 amazon-web-services aws-cloudformation amazon-dynamodb

我正在尝试在现有的 dynmoDB 表上设置 TTL

出错

发生错误:传入 - 属性 TimeToLiveSpecification 的值必须是一个对象。

这是我的模板

    Incoming:
  Type: AWS::DynamoDB::Table
  Properties:
    TableName: table-test
    KeySchema:
      - AttributeName: number
        KeyType: HASH
      - AttributeName: number2
        KeyType: RANGE
    AttributeDefinitions:
      - AttributeName: number
        AttributeType: S
      - AttributeName: number2
        AttributeType: S
    TimeToLiveSpecification: 
      - AttributeName: TimeToLive
        Enabled: true
    ProvisionedThroughput:
      ReadCapacityUnits: 2
      WriteCapacityUnits: 2
Run Code Online (Sandbox Code Playgroud)

我可能缺少一些简单的东西,但无法弄清楚

Sha*_*ler 9

想通了,在-靠近AttributeNameTimeToLiveSpecification部分的地方放错了地方

Incoming:
  Type: AWS::DynamoDB::Table
  Properties:
    TableName: table-test
    KeySchema:
      - AttributeName: number
        KeyType: HASH
      - AttributeName: number2
        KeyType: RANGE
    AttributeDefinitions:
      - AttributeName: number
        AttributeType: S
      - AttributeName: number2
        AttributeType: S
    TimeToLiveSpecification: 
        AttributeName: TimeToLive   # <-- stray dash was here
        Enabled: true
    ProvisionedThroughput:
      ReadCapacityUnits: 2
      WriteCapacityUnits: 2
Run Code Online (Sandbox Code Playgroud)