[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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン