Namespace Amazon.CDK.AWS.KinesisAnalyticsFlink
Kinesis Analytics Flink
---AWS CDK v1 has reached End-of-Support on 2023-06-01.
This package is no longer being updated, and users should migrate to AWS CDK v2.
For more information on how to migrate, see the Migrating to AWS CDK v2 guide.
This package provides constructs for creating Kinesis Analytics Flink applications. To learn more about using using managed Flink applications, see the AWS developer guide.
Creating Flink Applications
To create a new Flink application, use the Application
construct:
using Path;
using Amazon.CDK;
using Amazon.CDK.AWS.KinesisAnalyticsFlink;
using Amazon.CDK.AWS.CloudWatch;
var app = new App();
var stack = new Stack(app, "FlinkAppTest");
var flinkApp = new Application(stack, "App", new ApplicationProps {
Code = ApplicationCode.FromAsset(Join(__dirname, "code-asset")),
Runtime = Runtime.FLINK_1_11
});
new Alarm(stack, "Alarm", new AlarmProps {
Metric = flinkApp.MetricFullRestarts(),
EvaluationPeriods = 1,
Threshold = 3
});
app.Synth();
The code
property can use fromAsset
as shown above to reference a local jar
file in s3 or fromBucket
to reference a file in s3.
using Path;
using Amazon.CDK.AWS.S3.Assets;
using Amazon.CDK;
using Amazon.CDK.AWS.KinesisAnalyticsFlink;
var app = new App();
var stack = new Stack(app, "FlinkAppCodeFromBucketTest");
var asset = new Asset(stack, "CodeAsset", new AssetProps {
Path = Join(__dirname, "code-asset")
});
var bucket = asset.Bucket;
var fileKey = asset.S3ObjectKey;
new Application(stack, "App", new ApplicationProps {
Code = ApplicationCode.FromBucket(bucket, fileKey),
Runtime = Runtime.FLINK_1_11
});
app.Synth();
The propertyGroups
property provides a way of passing arbitrary runtime
properties to your Flink application. You can use the
aws-kinesisanalytics-runtime library to retrieve these
properties.
Bucket bucket;
var flinkApp = new Application(this, "Application", new ApplicationProps {
PropertyGroups = new PropertyGroups {
FlinkApplicationProperties = new Dictionary<string, string> {
{ "inputStreamName", "my-input-kinesis-stream" },
{ "outputStreamName", "my-output-kinesis-stream" }
}
},
// ...
Runtime = Runtime.FLINK_1_13,
Code = ApplicationCode.FromBucket(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 bucket;
var flinkApp = new Application(this, "Application", new ApplicationProps {
Code = ApplicationCode.FromBucket(bucket, "my-app.jar"),
Runtime = Runtime.FLINK_1_13,
CheckpointingEnabled = true, // default is true
CheckpointInterval = Duration.Seconds(30), // default is 1 minute
MinPauseBetweenCheckpoints = Duration.Seconds(10), // default is 5 seconds
LogLevel = LogLevel.ERROR, // default is INFO
MetricsLevel = MetricsLevel.PARALLELISM, // default is APPLICATION
AutoScalingEnabled = false, // default is true
Parallelism = 32, // default is 1
ParallelismPerKpu = 2, // default is 1
SnapshotsEnabled = false, // default is true
LogGroup = new LogGroup(this, "LogGroup")
});
Classes
Application | (experimental) The L2 construct for Flink Kinesis Data Applications. |
ApplicationCode | (experimental) Code configuration providing the location to a Flink application JAR file. |
ApplicationCodeConfig | (experimental) The return type of {@link ApplicationCode.bind}. This represents CloudFormation configuration and an s3 bucket holding the Flink application JAR file. |
ApplicationProps | (experimental) Props for creating an Application construct. |
LogLevel | (experimental) Available log levels for Flink applications. |
MetricsLevel | (experimental) Granularity of metrics sent to CloudWatch. |
PropertyGroups | (experimental) Interface for building AWS::KinesisAnalyticsV2::Application PropertyGroup configuration. |
Runtime | (experimental) Available Flink runtimes for Kinesis Analytics. |
Interfaces
IApplication | (experimental) An interface expressing the public properties on both an imported and CDK-created Flink application. |
IApplicationCodeConfig | (experimental) The return type of {@link ApplicationCode.bind}. This represents CloudFormation configuration and an s3 bucket holding the Flink application JAR file. |
IApplicationProps | (experimental) Props for creating an Application construct. |
IPropertyGroups | (experimental) Interface for building AWS::KinesisAnalyticsV2::Application PropertyGroup configuration. |