> **Experimental**
>
> `@aws-cdk/aws-mediaconnect-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# Flow

Defines an AWS Elemental MediaConnect Flow.

Extends: Construct › Resource › Flow
Implements: IFlow, IResource, IEnvironmentAware, IFlowRef, IConstruct, IDependable

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/flow.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0-alpha.0/packages/@aws-cdk/aws-mediaconnect-alpha/lib/flow.ts#L1343)

## Example

```ts
declare const stack: Stack;
declare const securityGroup: ec2.ISecurityGroup;
declare const subnet: ec2.ISubnet;
declare const role: iam.IRole;

const vpcInterface = VpcInterface.define({
  vpcInterfaceName: 'my-vpc-interface',
  role: role,
  securityGroups: [securityGroup],
  subnet: subnet,
});

const flow = new Flow(stack, 'MyFlow', {
  source: SourceConfiguration.rist({
    flowSourceName: 'vpc-source',
    description: 'VPC-based source',
    port: 5000,
    maxLatency: Duration.millis(2000),
    network: NetworkConfiguration.vpc(vpcInterface),
  }),
  vpcInterfaces: [vpcInterface],
});
```

## Initializer

```ts
new Flow(scope: Construct, id: string, props: FlowProps)
```

## Construct Props

- `availabilityZone`: string — The Availability Zone that you want to create the flow in.

  **Default:** chosen by MediaConnect

  These options are limited to the Availability Zones within the current AWS Region.

- `encodingConfig`: [EncodingConfig](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.EncodingConfig.html) — Encoding configuration applied to the NDI source when transcoding it to a transport stream for downstream distribution.

  **Default:** no encoding config; required for NDI sources

  Required when the flow source uses the NDI SpeedHQ protocol
  (see {@link SourceConfiguration.ndi}).

- `flowName`: string = autogenerated — The name of the flow.

- `flowSize`: [FlowSize](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.FlowSize.html) — Determines the processing capacity and feature set of the flow.

  **Default:** undefined; when omitted, MediaConnect applies FlowSize.MEDIUM at deploy time

  Set this optional parameter to LARGE if you want to enable NDI outputs on the flow.

- `maintenanceConfiguration`: [MaintenanceWindow](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.MaintenanceWindow.html) — The maintenance window for the flow.

  **Default:** chosen by MediaConnect

- `mediaStreams`: [MediaStream](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.MediaStream.html)[] — The media streams that are associated with the flow.

  **Default:** No Media Streams

  After you associate a media stream with a source, you can also associate it with outputs on the flow.

- `ndiConfig`: [NdiConfig](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.NdiConfig.html) — Specifies the configuration settings for a flow's NDI source or output.

  **Default:** No NDI Configuration applied

  Required when the flow includes an NDI source or output.

- `source`: [SourceConfiguration](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.SourceConfiguration.html) (required) — The settings for the source that you want to use for the new flow.

- `sourceFailoverConfig`: [FailoverConfig](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.FailoverConfig.html) — The settings for source failover.

  **Default:** No source failover configuration applied

- `sourceMonitoringConfig`: [SourceMonitoringConfig](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.SourceMonitoringConfig.html) — The settings for source monitoring.

  **Default:** No source monitoring configuration applied

- `vpcInterfaces`: [VpcInterfaceConfig](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.VpcInterfaceConfig.html)[] — The VPC Interfaces for this flow.

  **Default:** No VPC Interface configuration applied

## Properties

- `egressIp`: string — The IP address that the flow uses to send outbound content.

- `env`: [ResourceEnvironment](/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.

- `flowArn`: string — The Amazon Resource Name (ARN) of the flow.

- `flowAvailabilityZone`: string — The Availability Zone that the flow was created in.

- `flowRef`: [FlowReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_mediaconnect.FlowReference.html) — A reference to this Flow resource.

  Required by the auto-generated IFlowRef interface.

- `grants`: [FlowGrants](/cdk/api/v2/docs/@aws-cdk_aws-mediaconnect-alpha.FlowGrants.html) — Collection of grant methods for this flow.

- `isFailoverEnabled`: boolean — Failover Configuration for flow.

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

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

- `sourceArn`: string — The Amazon Resource Name (ARN) of the source defined on the flow.

- `sourceIngestIp`: string — The IP address that the flow listens on for incoming content.

  Available for listener-style source protocols (RTP, RTP-FEC, RIST, SRT listener,
  Zixi push). Accessing this on SRT caller, entitlement, gateway bridge, router,
  CDI, JPEG XS, or imported flows throws — those sources don't expose a listening
  IP address.

- `sourceIngestPort`: string — The port that the flow listens on for incoming content.

  Available for the same listener-style source protocols as `sourceIngestIp`.
  Accessing this on SRT caller, entitlement, gateway bridge, router, CDI, JPEG XS,
  or imported flows throws.

- `sourceIngestUrl`: string — The full ingest URL for the flow source, combining protocol, IP, and port. For example: `srt://203.0.113.10:5000`.

  Available for listener-style source protocols (RTP, RTP-FEC, RIST, SRT listener,
  Zixi push) where the flow listens for an upstream sender. Accessing this on
  SRT caller, entitlement, gateway bridge, router, CDI, JPEG XS, or imported
  flows throws — those sources don't expose a single host:port ingest URL.

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

## Methods

- `addOutput(id: string, options: AddFlowOutputOptions): IFlowOutput` — Add an output to this flow.

- `addVpcInterface(vpc: VpcInterfaceConfig): VpcInterfaceConfig` — Add a VPC interface to this flow.

- `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`).

- `fromFlowArn(scope: Construct, id: string, flowArn: string): IFlow` (static) — Import an existing Flow from its ARN.

  Use `fromFlowAttributes()` instead if you need access to `sourceArn` or any other
  attribute not encoded in the flow ARN.

- `fromFlowAttributes(scope: Construct, id: string, attrs: FlowAttributes): IFlow` (static) — Creates a Flow construct that represents an external (imported) Flow.

- `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` — Create a CloudWatch metric for this flow.

- `metricSourceBitrate(props?: MetricOptions): Metric` — Metric for the bitrate of content ingested into the flow.

  Emits the `SourceBitRate` metric with dimension `FlowARN`, which aggregates across
  all sources on the flow. To narrow to a specific source on a multi-source flow, call
  {@link metric} with an additional `SourceARN` dimension.

- `metricSourceConnected(props?: MetricOptions): Metric` — Metric indicating the connection state of the source.

  1 for connected, 0 for disconnected.
  Applies only to Zixi, SRT, and RIST sources.

  Emits the `SourceConnected` metric with dimension `FlowARN`.

- `metricSourceDisconnections(props?: MetricOptions): Metric` — Metric for the number of times the source transitioned from connected to disconnected.

  Emits the `SourceDisconnections` metric with dimension `FlowARN`.

- `metricSourceDroppedPackets(props?: MetricOptions): Metric` — Metric for the number of packets lost during transit, measured before any error correction takes place.

  Emits the `SourceDroppedPackets` metric with dimension `FlowARN`.

- `metricSourceJitter(props?: MetricOptions): Metric` — Metric for the current network jitter of the source, measured in milliseconds.

  Emits the `SourceJitter` metric with dimension `FlowARN`.

- `metricSourceNotRecoveredPackets(props?: MetricOptions): Metric` — Metric for packets that were lost in transit and not recovered by error correction.

  Emits the `SourceNotRecoveredPackets` metric with dimension `FlowARN`, which aggregates
  across all sources on the flow.

- `metricSourcePacketLossPercent(props?: MetricOptions): Metric` — Metric for the percentage of packets lost during transit, even if they were recovered.

  Emits the `SourcePacketLossPercent` metric with dimension `FlowARN`.

- `metricSourceRoundTripTime(props?: MetricOptions): Metric` — Metric for the round-trip time between the source and MediaConnect. Applies only to RIST, Zixi, and SRT sources.

  Emits the `SourceRoundTripTime` metric with dimension `FlowARN`.

- `metricSourceSelected(props?: MetricOptions): Metric` — Metric indicating which source is selected for ingest when using `Failover` failover mode.

  A value of 1 indicates the source is being used as the input; 0 indicates it is standby.

  Emits the `SourceSelected` metric with dimension `FlowARN`. To narrow to a specific source,
  call {@link metric} with an additional `SourceARN` dimension.

- `metricSourceTotalPackets(props?: MetricOptions): Metric` — Metric for the total number of packets received by the flow sources.

  Emits the `SourceTotalPackets` metric with dimension `FlowARN`, which aggregates across
  all sources on the flow.

- `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.
