簡體   English   中英

如何在 DynamoDB 副本上設置時間點恢復

[英]How to set Point-In-Time Recovery on a DynamoDB Replica

我正在使用 CDK 在 DynamoDB 上創建一個全局表。 我想在所有副本上設置時間點恢復。 但是,PITR 僅在原始表上設置,而不在其他副本上設置。 這是我的代碼。

import { Stack, StackProps, App } from 'aws-cdk-lib';
import { Table, BillingMode, AttributeType, StreamViewType } from 'aws-cdk-lib/aws-dynamodb';

export class HelloCdkStack extends Stack {
  constructor(scope: App, id: string, props?: StackProps) {
    super(scope, id, props);

    new Table(this, 'Movies', {
      tableName: 'Music',
      partitionKey: {
        name: 'Artist', 
        type: AttributeType.STRING
      },
      sortKey: {
        name: 'SongTitle', 
        type: AttributeType.STRING
      },
      billingMode: BillingMode.PAY_PER_REQUEST,
      replicationRegions: ['eu-west-1'],
      pointInTimeRecovery: true,
      stream: StreamViewType.NEW_AND_OLD_IMAGES,
    });
  }
}

我想出了解決這個問題的方法。 我為全局表使用了 L1 構造。 我之前使用的 L2 Construct 似乎不支持為副本設置 PITR。 這是一個有效的代碼示例

new CfnGlobalTable(this, 'Music', {
      tableName: 'Music',
      attributeDefinitions: [
        {attributeName: 'SongTitle', attributeType: AttributeType.STRING},
      ],
      keySchema: [{attributeName: 'SongTitle', keyType: 'HASH'}],
      billingMode: BillingMode.PAY_PER_REQUEST,
      streamSpecification: { streamViewType: "NEW_AND_OLD_IMAGES" },
      replicas: ['us-east-1', 'eu-west-1'].map(region => {
        return {
          region: region,
          pointInTimeRecoverySpecification: { pointInTimeRecoveryEnabled: true }
        };
      })
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM