> **Experimental**
>
> `@aws-cdk/aws-kinesisanalytics-flink-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# Application

L2 construct · [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)

The L2 construct for Flink Kinesis Data Applications.

Extends: [Construct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Construct.html) › [Resource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Resource.html) › Application
Implements: [IApplication](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-kinesisanalytics-flink-alpha.IApplication.html), [IResource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResource.html), [IConnectable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IConnectable.html), [IGrantable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IGrantable.html), [IEnvironmentAware](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.IEnvironmentAware.html), IConstruct, IDependable

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- CloudFormation: [`AWS::KinesisAnalyticsV2::Application`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-kinesisanalyticsv2-application.html)
- L1 type: [`CfnApplicationV2`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kinesisanalytics.CfnApplicationV2.html)
- Source: [`lib/application.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-kinesisanalytics-flink-alpha/lib/application.ts#L943)

## Example

TypeScript:

```ts
declare const bucket: s3.Bucket;
const flinkApp = new flink.Application(this, 'Application', {
  propertyGroups: {
    FlinkApplicationProperties: {
      inputStreamName: 'my-input-kinesis-stream',
      outputStreamName: 'my-output-kinesis-stream',
    },
  },
  // ...
  runtime: flink.Runtime.FLINK_2_2,
  code: flink.ApplicationCode.fromBucket(bucket, 'my-app.jar'),
});
```

Python:

```python
# bucket: s3.Bucket

flink_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_2_2,
    code=flink.ApplicationCode.from_bucket(bucket, "my-app.jar")
)
```

Java:

```java
Bucket bucket;

Application flinkApp = Application.Builder.create(this, "Application")
        .propertyGroups(Map.of(
                "FlinkApplicationProperties", Map.of(
                        "inputStreamName", "my-input-kinesis-stream",
                        "outputStreamName", "my-output-kinesis-stream")))
        // ...
        .runtime(Runtime.FLINK_2_2)
        .code(ApplicationCode.fromBucket(bucket, "my-app.jar"))
        .build();
```

C#:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.KinesisAnalyticsFlink.Alpha
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")
});
```

Go:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkkinesisanalyticsflinkalpha/v2
var bucket Bucket

flinkApp := flink.NewApplication(this, jsii.String("Application"), &ApplicationProps{
	PropertyGroups: map[string]map[string]*string{
		"FlinkApplicationProperties": map[string]*string{
			"inputStreamName": jsii.String("my-input-kinesis-stream"),
			"outputStreamName": jsii.String("my-output-kinesis-stream"),
		},
	},
	// ...
	Runtime: flink.Runtime_FLINK_2_2(),
	Code: flink.ApplicationCode_FromBucket(bucket, jsii.String("my-app.jar")),
})
```

## Initializer

TypeScript:

```ts
new Application(scope: Construct, id: string, props: ApplicationProps)
```

Python:

```python
Application(scope: Construct, id: str, props: ApplicationProps)
```

Java:

```java
new Application(Construct scope, String id, ApplicationProps props)
```

C#:

```csharp
new Application(Construct scope, string id, ApplicationProps props)
```

Go:

```go
NewApplication(Scope Construct, Id *string, Props ApplicationProps)
```

## Construct Props

- `applicationName`: string — A name for your Application that is unique to an AWS account.

  **Default:** CloudFormation-generated name

- `autoScalingEnabled`: boolean = true — Whether the Kinesis Data Analytics service can increase the parallelism of the application in response to resource usage.

- `checkpointingEnabled`: boolean = true — Whether checkpointing is enabled while your application runs.

- `checkpointInterval`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The interval between checkpoints.

  **Default:** 1 minute

- `code`: [ApplicationCode](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-kinesisanalytics-flink-alpha.ApplicationCode.html) (required) — The Flink code asset to run.

- `logGroup`: [ILogGroup](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogGroup.html) — The log group to send log entries to.

  **Default:** CDK's default LogGroup

- `logLevel`: [LogLevel](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-kinesisanalytics-flink-alpha.LogLevel.html) = FlinkLogLevel.INFO — The level of log verbosity from the Flink application.

- `metricsLevel`: [MetricsLevel](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-kinesisanalytics-flink-alpha.MetricsLevel.html) = MetricsLevel.APPLICATION — Describes the granularity of the CloudWatch metrics for an application.

  Use caution with Parallelism level metrics. Parallelism granularity logs
  metrics for each parallel thread and can quickly become expensive when
  parallelism is high (e.g. > 64).

- `minPauseBetweenCheckpoints`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The minimum amount of time in to wait after a checkpoint finishes to start a new checkpoint.

  **Default:** 5 seconds

- `parallelism`: number = 1 — The initial parallelism for the application.

  Kinesis Data Analytics can
  stop the app, increase the parallelism, and start the app again if
  autoScalingEnabled is true (the default value).

- `parallelismPerKpu`: number = 1 — The Flink parallelism allowed per Kinesis Processing Unit (KPU).

- `propertyGroups`: { [key: string]: { [key: string]: string } } — Configuration PropertyGroups.

  **Default:** No property group configuration provided to the Flink app

  You can use these property groups to pass
  arbitrary runtime configuration values to your Flink app.

- `removalPolicy`: [RemovalPolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.DESTROY — Provide a RemovalPolicy to override the default.

- `role`: [IRole](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — A role to use to grant permissions to your application.

  **Default:** a new Role will be created

  Prefer omitting
  this property and using the default role.

- `runtime`: [Runtime](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-kinesisanalytics-flink-alpha.Runtime.html) (required) — The Flink version to use for this application.

- `securityGroups`: [ISecurityGroup](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — Security groups to use with a provided VPC.

  **Default:** a new security group is created for this application.

- `snapshotsEnabled`: boolean = true — Determines if Flink snapshots are enabled.

- `vpc`: [IVpc](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) — Deploy the Flink application in a VPC.

  **Default:** no VPC

- `vpcSubnets`: [SubnetSelection](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — Choose which VPC subnets to use.

  **Default:** SubnetType.PRIVATE_WITH_EGRESS subnets

## Properties

- `applicationArn`: string — The application ARN.

- `applicationName`: string — The name of the Flink application.

- `connections`: [Connections](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) — The network connections associated with this resource.

- `env`: [ResourceEnvironment](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `grantPrincipal`: [IPrincipal](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IPrincipal.html) — The principal to grant permissions to.

- `node`: [Node](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `role`: [IRole](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The application IAM role.

- `stack`: [Stack](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

## Methods

- `addToRolePolicy(policyStatement: PolicyStatement): boolean` — Implement the convenience `IApplication.addToPrincipalPolicy` method.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromApplicationArn(scope: Construct, id: string, applicationArn: string): IApplication` (static) — Import an existing application defined outside of CDK code by applicationArn.

- `fromApplicationAttributes(scope: Construct, id: string, attrs: ApplicationAttributes): IApplication` (static) — Import an existing application defined outside of CDK code.

- `fromApplicationName(scope: Construct, id: string, applicationName: string): IApplication` (static) — Import an existing Flink application defined outside of CDK code by applicationName.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `metric(metricName: string, props?: MetricOptions): Metric` — Return a CloudWatch metric associated with this Flink application.

  **Parameters**

  - `metricName` — The name of the metric.
  - `props` — Customization properties.

- `metricBackPressuredTimeMsPerSecond(props?: MetricOptions): Metric` — The time (in milliseconds) this task or operator is back pressured per second.

  Units: Milliseconds

  Reporting Level: Operator, Task, Parallelism

- `metricBusyTimePerMsPerSecond(props?: MetricOptions): Metric` — The time (in milliseconds) this task or operator is busy (neither idle nor back pressured) per second.

  Can be NaN, if the value could not be
  calculated.

  Units: Milliseconds

  Reporting Level: Operator, Task, Parallelism

- `metricCpuUtilization(props?: MetricOptions): Metric` — The overall percentage of CPU utilization across task managers.

  For
  example, if there are five task managers, Kinesis Data Analytics publishes
  five samples of this metric per reporting interval.

  Units: Percentage

  Reporting Level: Application

- `metricCurrentInputWatermark(props?: MetricOptions): Metric` — The last watermark this application/operator/task/thread has received.

  Units: Milliseconds

  Reporting Level: Application, Operator, Task, Parallelism

- `metricCurrentOutputWatermark(props?: MetricOptions): Metric` — The last watermark this application/operator/task/thread has received.

  Units: Milliseconds

  Reporting Level: Application, Operator, Task, Parallelism

- `metricDowntime(props?: MetricOptions): Metric` — The time elapsed during an outage for failing/recovering jobs.

  Units: Milliseconds

  Reporting Level: Application

- `metricFullRestarts(props?: MetricOptions): Metric` — The total number of times this job has fully restarted since it was submitted.

  This metric does not measure fine-grained restarts.

  Units: Count

  Reporting Level: Application

- `metricHeapMemoryUtilization(props?: MetricOptions): Metric` — Overall heap memory utilization across task managers.

  For example, if there
  are five task managers, Kinesis Data Analytics publishes five samples of
  this metric per reporting interval.

  Units: Percentage

  Reporting Level: Application

- `metricIdleTimeMsPerSecond(props?: MetricOptions): Metric` — The time (in milliseconds) this task or operator is idle (has no data to process) per second.

  Idle time excludes back pressured time, so if the task
  is back pressured it is not idle.

  Units: Milliseconds

  Reporting Level: Operator, Task, Parallelism

- `metricKpus(props?: MetricOptions): Metric` — The number of Kinesis Processing Units that are used to run your stream processing application.

  The average number of KPUs used each hour
  determines the billing for your application.

  Units: Count

  Reporting Level: Application

- `metricLastCheckpointDuration(props?: MetricOptions): Metric` — The time it took to complete the last checkpoint.

  Units: Milliseconds

  Reporting Level: Application

- `metricLastCheckpointSize(props?: MetricOptions): Metric` — The total size of the last checkpoint.

  Units: Bytes

  Reporting Level: Application

- `metricManagedMemoryTotal(props?: MetricOptions): Metric` — The total amount of managed memory.

  Units: Bytes

  Reporting Level: Application, Operator, Task, Parallelism

- `metricManagedMemoryUsed(props?: MetricOptions): Metric` — The amount of managed memory currently used.

  Units: Bytes

  Reporting Level: Application, Operator, Task, Parallelism

- `metricManagedMemoryUtilization(props?: MetricOptions): Metric` — Derived from managedMemoryUsed/managedMemoryTotal.

  Units: Percentage

  Reporting Level: Application, Operator, Task, Parallelism

- `metricNumberOfFailedCheckpoints(props?: MetricOptions): Metric` — The number of times checkpointing has failed.

  Units: Count

  Reporting Level: Application

- `metricNumLateRecordsDropped(props?: MetricOptions): Metric` — The number of records this operator or task has dropped due to arriving late.

  Units: Count

  Reporting Level: Application, Operator, Task, Parallelism

- `metricNumRecordsIn(props?: MetricOptions): Metric` — The total number of records this application, operator, or task has received.

  Units: Count

  Reporting Level: Application, Operator, Task, Parallelism

- `metricNumRecordsInPerSecond(props?: MetricOptions): Metric` — The total number of records this application, operator or task has received per second.

  Units: Count/Second

  Reporting Level: Application, Operator, Task, Parallelism

- `metricNumRecordsOut(props?: MetricOptions): Metric` — The total number of records this application, operator or task has emitted.

  Units: Count

  Reporting Level: Application, Operator, Task, Parallelism

- `metricNumRecordsOutPerSecond(props?: MetricOptions): Metric` — The total number of records this application, operator or task has emitted per second.

  Units: Count/Second

  Reporting Level: Application, Operator, Task, Parallelism

- `metricOldGenerationGCCount(props?: MetricOptions): Metric` — The total number of old garbage collection operations that have occurred across all task managers.

  Units: Count

  Reporting Level: Application

- `metricOldGenerationGCTime(props?: MetricOptions): Metric` — The total time spent performing old garbage collection operations.

  Units: Milliseconds

  Reporting Level: Application

- `metricThreadsCount(props?: MetricOptions): Metric` — The total number of live threads used by the application.

  Units: Count

  Reporting Level: Application

- `metricUptime(props?: MetricOptions): Metric` — The time that the job has been running without interruption.

  Units: Milliseconds

  Reporting Level: Application

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
