[CDK] 从DDB流启用Kinesis Data Stream

0

【以下的问题经过翻译处理】 我知道可能会存在CFN支持新功能延迟导致CDK支持新功能的限制。 我正在尝试通过此控制台菜单从DDB流中启用KDS (Kinesis Data Stream)。 从CDK是否可能实现这个功能?我搜索了一下最终放弃了。 我想知道你是否知道如何使用CDK实现这个功能。

profile picture
專家
已提問 6 個月前檢視次數 53 次
1 個回答
0

【以下的回答经过翻译处理】 您可以通过以下几行代码在CDK中完成此操作:

import * as cr from "@aws-cdk/custom-resources";

const ddbToKinesis = new cr.AwsCustomResource(
  this,
  "CustomResourceDDBtoKinesis",
  {
    policy: cr.AwsCustomResourcePolicy.fromStatements([
      new iam.PolicyStatement({
        actions: [
          "dynamodb:EnableKinesisStreamingDestination",
          "dynamodb:DisableKinesisStreamingDestination",
          "dynamodb:DescribeKinesisStreamingDestination",
        ],
        effect: iam.Effect.ALLOW,
        resources: [tableArn],
      }),
      new iam.PolicyStatement({
        actions: ["kinesis:*"],
        effect: iam.Effect.ALLOW,
        resources: [streamArn],
      }),
    ]),
    onCreate: {
      service: "DynamoDB",
      action: "enableKinesisStreamingDestination",
      parameters: {
        StreamArn: streamArn,
        TableName: tableName,
      },
      physicalResourceId: cr.PhysicalResourceId.of(Date.now().toString()),
    },
    onDelete: {
      service: "DynamoDB",
      action: "disableKinesisStreamingDestination",
      parameters: {
        StreamArn: replicationStream.streamArn,
        TableName: tableName,
      },
      physicalResourceId: cr.PhysicalResourceId.of(Date.now().toString()),
    },
    installLatestAwsSdk: true,
  }
);
profile picture
專家
已回答 6 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南