Package: aws-cdk.aws-kinesisanalytics-flink-alpha
Kinesis Analytics Flink---The APIs of higher level constructs in this module are experimental and under active development.
They are subject to non-backward compatible changes or removal in any future version. These are
not subject to theSemantic Versioningmodel and breaking changes will be
announced in the release notes. This means that while you may use them, you may need to update
your source code when upgrading to a newer version of this package.This package provides constructs for creating Kinesis Analytics Flink
applications. To learn more about using using managed Flink applications, see
theAWS developer
guide.Creating Flink ApplicationsTo create a new Flink application, use theApplicationconstruct:importpathaspathimportaws_cdk.aws_cloudwatchascloudwatchimportaws_cdkascoreimportaws_cdk.aws_kinesisanalytics_flink_alphaasflinkapp=core.App()stack=core.Stack(app,"FlinkAppTest")flink_app=flink.Application(stack,"App",code=flink.ApplicationCode.from_asset(path.join(__dirname,"code-asset")),runtime=flink.Runtime.FLINK_1_11)cloudwatch.Alarm(stack,"Alarm",metric=flink_app.metric_full_restarts(),evaluation_periods=1,threshold=3)app.synth()Thecodeproperty can usefromAssetas shown above to reference a local jar
file in s3 orfromBucketto reference a file in s3.importpathaspathimportaws_cdk.aws_s3_assetsasassetsimportaws_cdkascoreimportaws_cdk.aws_kinesisanalytics_flink_alphaasflinkapp=core.App()stack=core.Stack(app,"FlinkAppCodeFromBucketTest")asset=assets.Asset(stack,"CodeAsset",path=path.join(__dirname,"code-asset"))bucket=asset.bucketfile_key=asset.s3_object_keyflink.Application(stack,"App",code=flink.ApplicationCode.from_bucket(bucket,file_key),runtime=flink.Runtime.FLINK_1_11)app.synth()ThepropertyGroupsproperty provides a way of passing arbitrary runtime
properties to your Flink application. You can use the
aws-kinesisanalytics-runtime library toretrieve these
properties.# bucket: s3.Bucketflink_app=flink.Application(self,"Application",property_groups={"FlinkApplicationProperties":{"input_stream_name":"my-input-kinesis-stream","output_stream_name":"my-output-kinesis-stream"}},# ...runtime=flink.Runtime.FLINK_1_15,code=flink.ApplicationCode.from_bucket(bucket,"my-app.jar"))Flink applications also have specific configuration for passing parameters
when the Flink job starts. These include parameters for checkpointing,
snapshotting, monitoring, and parallelism.# bucket: s3.Bucketflink_app=flink.Application(self,"Application",code=flink.ApplicationCode.from_bucket(bucket,"my-app.jar"),runtime=flink.Runtime.FLINK_1_15,checkpointing_enabled=True,# default is truecheckpoint_interval=Duration.seconds(30),# default is 1 minutemin_pause_between_checkpoints=Duration.seconds(10),# default is 5 secondslog_level=flink.LogLevel.ERROR,# default is INFOmetrics_level=flink.MetricsLevel.PARALLELISM,# default is APPLICATIONauto_scaling_enabled=False,# default is trueparallelism=32,# default is 1parallelism_per_kpu=2,# default is 1snapshots_enabled=False,# default is truelog_group=logs.LogGroup(self,"LogGroup"))Flink applications can optionally be deployed in a VPC:# bucket: s3.Bucket# vpc: ec2.Vpcflink_app=flink.Application(self,"Application",code=flink.ApplicationCode.from_bucket(bucket,"my-app.jar"),runtime=flink.Runtime.FLINK_1_15,vpc=vpc)