AWS CDK Kinesis Firehose (Alpha)

2.186.0a0 · deprecated · verified Fri Apr 17

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

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a Kinesis Firehose Delivery Stream using the stable `aws_cdk.aws_kinesisfirehose` module. It creates a simple Firehose stream configured to deliver data directly to an S3 bucket, including the necessary IAM role. Ensure your AWS credentials and CDK environment variables (`CDK_DEFAULT_ACCOUNT`, `CDK_DEFAULT_REGION`) are configured.

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()

view raw JSON →