{"id":9520,"library":"aws-cdk-aws-kinesis","title":"AWS CDK Kinesis Constructs","description":"The AWS Cloud Development Kit (CDK) Construct Library for AWS Kinesis provides high-level constructs for defining Kinesis streams using familiar programming languages. This entry specifically targets version 1.204.0, which is part of the v1 branch of the AWS CDK. The AWS CDK typically has frequent minor releases (often weekly or bi-weekly) and less frequent major releases (e.g., v1 to v2), with v2 being the currently recommended and actively developed version.","status":"maintenance","version":"1.204.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws","cdk","kinesis","iac","cloud-development-kit","serverless","data-stream"],"install":[{"cmd":"pip install aws-cdk-aws-kinesis","lang":"bash","label":"Install v1 Kinesis Constructs"}],"dependencies":[{"reason":"Required for core CDK constructs, app, and stack definitions when using AWS CDK v1.","package":"aws-cdk.core","optional":false},{"reason":"Underlying construct programming model library, used by AWS CDK v1.","package":"constructs","optional":false}],"imports":[{"note":"This package (`aws-cdk-aws-kinesis`) is for AWS CDK v1. V2 consolidated all constructs under `aws_cdk_lib` and uses a different import path. Ensure `aws-cdk.core` is also imported for v1.","wrong":"from aws_cdk_lib import aws_kinesis as kinesis","symbol":"Stream","correct":"from aws_cdk import aws_kinesis as kinesis"}],"quickstart":{"code":"import aws_cdk as cdk\nfrom aws_cdk import aws_kinesis as kinesis\nfrom constructs import Construct\n\nclass MyKinesisStack(cdk.Stack):\n    def __init__(self, scope: Construct, id: str, **kwargs) -> None:\n        super().__init__(scope, id, **kwargs)\n\n        # Create a Kinesis Data Stream\n        kinesis.Stream(self, \"MyCDKStream\",\n                       stream_name=\"MyCDKPythonStream\",\n                       shard_count=1,\n                       retention_period=cdk.Duration.hours(24))\n\napp = cdk.App()\nMyKinesisStack(app, \"MyKinesisStack\")\napp.synth()","lang":"python","description":"This quickstart demonstrates how to create a basic Kinesis Data Stream with a single shard and 24-hour retention using AWS CDK v1 constructs. To run this, you will also need to have `aws-cdk.core` installed (`pip install aws-cdk.core`)."},"warnings":[{"fix":"For v2, change your imports from `from aws_cdk import aws_kinesis` to `from aws_cdk_lib import aws_kinesis`. Install `aws-cdk-lib` instead of individual `aws-cdk-aws-*` packages. Use the `cdk migrate` command-line tool for assistance with updating code.","message":"AWS CDK v1 is in maintenance mode; v2 is the current major version. Migrating from v1 to v2 involves significant changes to package structure and import paths. For v2, all construct libraries are consolidated under `aws-cdk-lib`.","severity":"breaking","affected_versions":"All versions of AWS CDK v1 when migrating to v2"},{"fix":"Set the `retention_period` property when defining your `Stream` construct. For example: `retention_period=cdk.Duration.hours(7 * 24)` for 7 days.","message":"Kinesis Data Streams have a default data retention period of 24 hours. If you require longer data retention (up to 365 days), you must explicitly configure it.","severity":"gotcha","affected_versions":"All versions of aws-cdk-aws-kinesis"},{"fix":"Set `encryption=kinesis.StreamEncryption.KMS` and optionally `encryption_key` to a specific KMS key when creating the `Stream` construct. Example: `encryption=kinesis.StreamEncryption.KMS, encryption_key=kms.Key.from_key_arn(self, \"MyKey\", \"arn:aws:kms:...\")`","message":"By default, Kinesis Data Streams are encrypted at rest using a Kinesis-owned AWS KMS key. If you need to use a customer-managed KMS key (CMK) for compliance or specific key management requirements, you must specify it.","severity":"gotcha","affected_versions":"All versions of aws-cdk-aws-kinesis"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"If you intend to use AWS CDK v1, ensure your imports follow the `from aws_cdk import aws_kinesis` pattern and `pip install aws-cdk.core`. If you intend to use v2, `pip install aws-cdk-lib` and update your imports accordingly.","cause":"You are attempting to use AWS CDK v2 import paths (`from aws_cdk_lib import ...`) while your project is configured for or has only AWS CDK v1 packages (`aws-cdk-aws-kinesis`, `aws-cdk.core`) installed.","error":"ModuleNotFoundError: No module named 'aws_cdk_lib'"},{"fix":"Ensure all necessary imports are present and aliased correctly (`import aws_cdk as cdk`, `from aws_cdk import aws_kinesis as kinesis`, `from constructs import Construct`). Verify that you are instantiating constructs correctly, passing `self`, `id`, and props.","cause":"This error often occurs when you try to call a module directly, rather than accessing a construct within it (e.g., `kinesis.Stream()` instead of `kinesis.Stream(...)`), or if there's a missing `import aws_cdk as cdk` or `from constructs import Construct` for v1 applications.","error":"TypeError: 'module' object is not callable"},{"fix":"Verify the `stream_name` or `stream_arn` in your CDK code matches the actual resource. If importing, ensure the stream exists. If creating, ensure you're deploying to the correct AWS region. For cross-stack references, ensure the producer stack is deployed first.","cause":"This runtime error typically indicates that the Kinesis stream either does not exist, or the name/ARN specified in the CDK code does not match an existing stream, especially when attempting to import an existing resource. It can also happen due to region mismatch or if the stream was manually deleted after deployment.","error":"Resource CFN_E_TARGET_NOT_FOUND error with message \"Stream <stream-name> not found\" when deploying."}]}