Amazon.CDK.AWS.KinesisAnalyticsFlink.Alpha
A CDK Construct Library for Kinesis Analytics Flink applications (Stability: Experimental)
Install
| Product | Versions |
|---|---|
| .NET |
README
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 the Semantic Versioning model 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 the AWS developer guide.
Creating Flink Applications
To create a new Flink application, use the Application construct:
using Path;
using Amazon.CDK.IntegTests.Alpha;
using Amazon.CDK;
using Amazon.CDK.AWS.CloudWatch;
using Amazon.CDK.AWS.Kinesisanalytics.Flink.Alpha;
var app = new App();
var stack = new Stack(app, "FlinkAppTest");
var flinkRuntimes = new [] { Runtime.FLINK_1_15, Runtime.FLINK_1_18, Runtime.FLINK_1_19, Runtime.FLINK_1_20, Runtime.FLINK_2_2 };
flinkRuntimes.ForEach((runtime) => {
const flinkApp = new flink.Application(stack, `App-${runtime.value}`, {
code: flink.ApplicationCode.fromAsset(path.join(__dirname, 'code-asset')),
runtime: runtime,
});
new cloudwatch.Alarm(stack, `Alarm-${runtime.value}`, {
metric: flinkApp.metricFullRestarts(),
evaluationPeriods: 1,
threshold: 3,
});
});
new IntegTest(app, "ApplicationTest", new IntegTestProps {
TestCases = new [] { stack }
});
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.
new Application(stack, "App", new ApplicationProps {
Code = ApplicationCode.FromBucket(bucket, fileKey),
Runtime = Runtime.FLINK_1_19
});
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 Dictionary<string, IDictionary<string, string>> {
{ "FlinkApplicationProperties", new Dictionary<string, string> {
{ "inputStreamName", "my-input-kinesis-stream" },
{ "outputStreamName", "my-output-kinesis-stream" }
} }
},
// ...
Runtime = Runtime.FLINK_2_2,
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_2_2,
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")
});
Flink applications can optionally be deployed in a VPC:
Bucket bucket;
Vpc vpc;
var flinkApp = new Application(this, "Application", new ApplicationProps {
Code = ApplicationCode.FromBucket(bucket, "my-app.jar"),
Runtime = Runtime.FLINK_2_2,
Vpc = vpc
});
Changes from Previous Version
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.