AWS CDK Kinesis Firehose (Alpha)
This AWS Cloud Development Kit (CDK) module provides constructs for provisioning AWS Kinesis Firehose resources. Currently at version 2.186.0a0, this `alpha` module is deprecated. All its constructs have been moved to the stable `aws-cdk-aws-kinesisfirehose` module, which is part of `aws-cdk-lib`. CDK follows a rapid release cadence for patch versions and regular minor version updates.
Common errors
-
ModuleNotFoundError: No module named 'aws_cdk.aws_kinesisfirehose_alpha'
cause The `aws-cdk-aws-kinesisfirehose-alpha` package is not installed, or you are trying to import from it after it has been deprecated and its functionality moved.fixInstall `aws-cdk-lib` and `constructs` using `pip install aws-cdk-lib constructs`. Then, update your import statements to `from aws_cdk.aws_kinesisfirehose import ...`. -
AttributeError: module 'aws_cdk.aws_kinesisfirehose_alpha' has no attribute 'CfnDeliveryStream'
cause You are using an outdated version of the alpha module, or the specific construct you are looking for has been moved, renamed, or removed during the alpha phase or in the migration to the stable module.fixMigrate to the stable `aws_cdk.aws_kinesisfirehose` module (part of `aws-cdk-lib`) and refer to its current documentation for accurate construct names and properties.
Warnings
- breaking The `aws-cdk-aws-kinesisfirehose-alpha` module is deprecated. Its constructs have been moved to the stable `aws_cdk.aws_kinesisfirehose` namespace, which is now part of `aws-cdk-lib`. Continuing to use the alpha package will lead to outdated APIs and potential `ModuleNotFoundError` in future CDK versions.
- gotcha After migrating from the alpha module, ensure all import statements are updated from `from aws_cdk.aws_kinesisfirehose_alpha import ...` to `from aws_cdk.aws_kinesisfirehose import ...`.
- gotcha Alpha modules are subject to breaking changes without notice. When migrating to the stable module, review the API documentation for any subtle differences in construct properties, default behaviors, or methods that might have evolved during the stabilization process.
Install
-
pip install aws-cdk-lib aws-cdk.aws-kinesisfirehose constructs -
pip install aws-cdk-aws-kinesisfirehose-alpha
Imports
- CfnDeliveryStream
from aws_cdk.aws_kinesisfirehose_alpha import CfnDeliveryStream
from aws_cdk.aws_kinesisfirehose import CfnDeliveryStream
Quickstart
import os
from aws_cdk import (
Stack,
App,
Environment,
aws_s3 as s3,
aws_iam as iam,
)
from aws_cdk.aws_kinesisfirehose import CfnDeliveryStream
from constructs import Construct
class FirehoseStack(Stack):
def __init__(self, scope: Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
# S3 bucket for Firehose destination
bucket = s3.Bucket(self, "FirehoseDestinationBucket")
# IAM Role for Firehose
firehose_role = iam.Role(
self, "FirehoseRole",
assumed_by=iam.ServicePrincipal("firehose.amazonaws.com"),
managed_policies=[
iam.ManagedPolicy.from_aws_managed_policy_name("AmazonKinesisFirehoseFullAccess")
]
)
bucket.grant_read_write(firehose_role)
# Kinesis Firehose Delivery Stream to S3
CfnDeliveryStream(
self, "MyDeliveryStream",
delivery_stream_name="MyTestDeliveryStream",
delivery_stream_type="DirectPut", # Or KinesisStreamAsSource
extended_s3_destination_configuration=CfnDeliveryStream.ExtendedS3DestinationConfigurationProperty(
bucket_arn=bucket.bucket_arn,
role_arn=firehose_role.role_arn,
buffering_hints=CfnDeliveryStream.BufferingHintsProperty(
interval_in_seconds=300,
size_in_m_bs=5
),
compression_format="UNCOMPRESSED",
prefix="firehose/data/",
error_output_prefix="firehose/errors/"
)
)
app = App()
FirehoseStack(app, "FirehoseExampleStack",
env=Environment(
account=os.environ.get("CDK_DEFAULT_ACCOUNT"),
region=os.environ.get("CDK_DEFAULT_REGION")
)
)
app.synth()