使用 CloudFormation 更新 DynamoDB 的 TimeToLiveSpecification

Updating TimeToLiveSpecification for DynamoDB using CloudFormation

我已经像这样使用 CloudFormation 部署了 DynamoDB table:

  exampleTable:
    Type: AWS::DynamoDB::Table
    Properties:
      BillingMode: PAY_PER_REQUEST
      KeySchema:
        - AttributeName: id
          KeyType: HASH
        - AttributeName: prop
          KeyType: RANGE
      TimeToLiveSpecification:
        AttributeName: foo
        Enabled: true

将 TTL 属性更改为 bar 已成功部署,但更改未反映到仪表板。

https://docs.amazonaws.cn/en_us/amazondynamodb/latest/developerguide/time-to-live-ttl-before-you-start.html#time-to-live-ttl-before-you-start-notes

You cannot reconfigure TTL to look for a different attribute. You must disable TTL, and then reenable TTL with the new attribute going forward.

即使使用 CloudFormation 也需要部署 2 次吗? (一次用于禁用 TTL,一次用于使用新属性名称启用 TTL)

Do I need to deploy 2 times even when using CloudFormation?

是的。 CloudFormation 文档 AttributeName:

中明确说明了必须先禁用它这一事实

To update this property, you must first disable TTL then enable TTL with the new attribute name.