[CDK] Enable Kinesis DS from DDB stream

0

I know that CDK may have limitation due to CFN having some lag on new features. I am trying to enable Kinesis DS from DDB stream like this console menu.

Is this possible from CDK? I searched and eventually gave up. I was wondering if you know this enablement from CDK.

profile pictureAWS
demandé il y a 3 ans895 vues
1 réponse
0
Réponse acceptée

You can do this in CDK by few lines of code:

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,
  }
);
répondu il y a 3 ans
profile picture
EXPERT
vérifié il y a un mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions