AWS::MediaConnect Construct Library
---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.
AWS Elemental MediaConnect
AWS Elemental MediaConnect is a high-quality transport service for live video. It provides the reliability and security of satellite and fiber-optic combined with the flexibility, agility, and economics of IP-based networks. MediaConnect enables you to build mission-critical live video workflows in a fraction of the time and cost of satellite or fiber services.
This package contains constructs for working with AWS Elemental MediaConnect, allowing you to define Flows, Bridges, Gateways, Router Inputs, Router Outputs, and Router Network Interfaces for transporting live video streams.
For further information on AWS Elemental MediaConnect, see the documentation.
Table of Contents
Router Resources
MediaConnect routers provide high-performance, low-latency video routing capabilities for building complex live video workflows. Router resources include network interfaces, inputs, and outputs.
How Router Resources Relate
Router resources work together in a pipeline:
A RouterNetworkInterface defines the network connectivity (public internet or VPC). Required for standard protocol-based inputs and outputs, but not needed when connecting to MediaLive inputs or MediaConnect flows directly.
A RouterInput is the entry point — it receives video from a source via a protocol (RTP, SRT, RIST), or from a MediaConnect flow.
A RouterOutput is the exit point — it sends video to a destination via a protocol, to a MediaLive input, or to a MediaConnect flow.
A typical camera-to-cloud workflow looks like:
Camera → RouterNetworkInterface → RouterInput (SRT) → [Router] → RouterOutput (MediaLive) → MediaLive Channel
The router sits in the middle, routing content from inputs to outputs. You can have many outputs per input — for example, one camera feed going to both a MediaLive channel and a MediaConnect flow simultaneously.
End-to-End Example: SRT Source to MediaLive
Here’s a complete example showing how to connect an SRT source through a router to MediaLive:
# stack: Stack
# media_live_input: medialive.CfnInput
# 1. A public network interface for the SRT input
network_interface = RouterNetworkInterface(stack, "NetworkInterface",
router_network_interface_name="camera-network",
configuration=RouterNetworkConfiguration.public_network(
cidr=["203.0.113.0/24"]
)
)
# 2. A router input receiving SRT from an upstream encoder
input = RouterInput(stack, "Input",
router_input_name="camera-input",
maximum_bitrate=Bitrate.mbps(10),
routing_scope=RoutingScope.REGIONAL,
tier=RouterInputTier.INPUT_20,
configuration=RouterInputConfiguration.standard(
network_interface=network_interface,
protocol=RouterInputProtocol.srt_listener(
port=9000,
minimum_latency=Duration.millis(200)
)
)
)
# 3. A router output delivering to MediaLive
output = RouterOutput(stack, "Output",
router_output_name="medialive-output",
maximum_bitrate=Bitrate.mbps(10),
routing_scope=RoutingScope.REGIONAL,
tier=RouterOutputTier.OUTPUT_20,
configuration=RouterOutputConfiguration.media_live_input(
media_live_input_arn=media_live_input.attr_arn,
media_live_pipeline_id=MediaLivePipeline.PIPELINE_0
)
)
This gives you a complete pipeline: the encoder pushes SRT to the network interface, the router receives it as an input, and the router output delivers it to MediaLive. For routing rules — including how bitrate affects which outputs can receive which inputs — see the documentation.
Router Network Interfaces
Network interfaces define the network connectivity for router inputs and outputs:
Public Network Interface
# stack: Stack
public_interface = RouterNetworkInterface(stack, "PublicInterface",
router_network_interface_name="public-interface",
configuration=RouterNetworkConfiguration.public_network(
cidr=["203.0.113.0/24"]
)
)
Private Network Interface
# stack: Stack
# security_group: ec2.ISecurityGroup
# subnet: ec2.ISubnet
private_interface = RouterNetworkInterface(stack, "PrivateInterface",
router_network_interface_name="private-interface",
configuration=RouterNetworkConfiguration.vpc(
security_groups=[security_group],
subnet=subnet
)
)
Router Inputs
Router inputs receive live video streams from various sources and make them available for routing:
Standard Input with RTP Protocol
# stack: Stack
# network_interface: RouterNetworkInterface
input = RouterInput(stack, "RtpInput",
router_input_name="rtp-input",
maximum_bitrate=Bitrate.mbps(10),
routing_scope=RoutingScope.REGIONAL,
# tier defaults to RouterInputTier.INPUT_20 (lowest cost)
configuration=RouterInputConfiguration.standard(
network_interface=network_interface,
protocol=RouterInputProtocol.rtp(
port=5000
)
)
)
Failover Input Configuration
# stack: Stack
# network_interface: RouterNetworkInterface
input = RouterInput(stack, "FailoverInput",
router_input_name="failover-input",
maximum_bitrate=Bitrate.mbps(10),
routing_scope=RoutingScope.REGIONAL,
tier=RouterInputTier.INPUT_50,
configuration=RouterInputConfiguration.failover(
network_interface=network_interface,
protocols=[
RouterInputProtocol.rist(
port=5000,
recovery_latency=Duration.millis(1000)
),
RouterInputProtocol.rist(
port=5002, # Must not be consecutive with primary port
recovery_latency=Duration.millis(1000)
)
],
source_priority=SourcePriorityConfig.primary_secondary(PrimarySource.FIRST_SOURCE)
)
)
MediaConnect Flow Input
Connect a router input to an existing MediaConnect flow:
# stack: Stack
# flow: Flow
# flow_output: FlowOutput
input = RouterInput(stack, "FlowInput",
router_input_name="flow-input",
maximum_bitrate=Bitrate.mbps(20),
routing_scope=RoutingScope.REGIONAL,
tier=RouterInputTier.INPUT_50,
configuration=RouterInputConfiguration.media_connect_flow(
flow=flow,
flow_output=flow_output
)
)
Or prepare a router input for a flow connection without specifying the flow (requires explicit availability zone):
# stack: Stack
input = RouterInput(stack, "FlowInputNoConnection",
router_input_name="flow-input-no-connection",
maximum_bitrate=Bitrate.mbps(20),
routing_scope=RoutingScope.REGIONAL,
tier=RouterInputTier.INPUT_50,
configuration=RouterInputConfiguration.media_connect_flow_without_connection(
availability_zone="us-east-1a"
)
)
Router Outputs
Router outputs send video streams to various destinations including standard protocols, MediaLive inputs, and MediaConnect flows:
Standard Output with SRT Protocol
# stack: Stack
# network_interface: RouterNetworkInterface
output = RouterOutput(stack, "SrtOutput",
router_output_name="srt-output",
maximum_bitrate=Bitrate.mbps(10),
routing_scope=RoutingScope.REGIONAL,
# tier defaults to RouterOutputTier.OUTPUT_20 (lowest cost)
configuration=RouterOutputConfiguration.standard(
protocol=RouterOutputProtocol.srt_listener(
port=9001,
minimum_latency=Duration.millis(200)
),
network_interface=network_interface
)
)
Note: The
tierproperty defaults to the lowest (and cheapest) tier:INPUT_20for Router Inputs andOUTPUT_20for Router Outputs. The construct validates thatmaximumBitratedoes not exceed the tier’s capacity (20, 50, or 100 Mbps) at synth time. Per the documentation, if an input is 20 Mbps you can’t route it to an output set up for less than 20 Mbps.
MediaLive Output
Note (breaking change in the future): MediaLive configuration is currently passed in as mediaLiveInputArn but when L2 construct available, this will be updated to use the construct instead.
Connect a router output to an existing MediaLive input:
# stack: Stack
# media_live_input: medialive.CfnInput
output = RouterOutput(stack, "MediaLiveOutput",
router_output_name="medialive-output",
maximum_bitrate=Bitrate.mbps(15),
routing_scope=RoutingScope.GLOBAL,
tier=RouterOutputTier.OUTPUT_50,
configuration=RouterOutputConfiguration.media_live_input(
media_live_input_arn=media_live_input.attr_arn,
media_live_pipeline_id=MediaLivePipeline.PIPELINE_0
)
)
Or prepare a router output for a MediaLive connection without specifying the input (requires explicit availability zone):
# stack: Stack
output = RouterOutput(stack, "MediaLiveOutputNoConnection",
router_output_name="medialive-output-no-connection",
maximum_bitrate=Bitrate.mbps(15),
routing_scope=RoutingScope.GLOBAL,
tier=RouterOutputTier.OUTPUT_50,
configuration=RouterOutputConfiguration.media_live_input_without_connection(
availability_zone="us-east-1a"
)
)
MediaConnect Flow Output
Connect a router output to an existing MediaConnect flow:
# stack: Stack
# flow: Flow
output = RouterOutput(stack, "FlowOutput",
router_output_name="flow-output",
maximum_bitrate=Bitrate.mbps(20),
routing_scope=RoutingScope.REGIONAL,
tier=RouterOutputTier.OUTPUT_100,
configuration=RouterOutputConfiguration.media_connect_flow(
flow=flow
)
)
Or prepare a router output for a flow connection without specifying the flow (requires explicit availability zone):
# stack: Stack
output = RouterOutput(stack, "FlowOutputNoConnection",
router_output_name="flow-output-no-connection",
maximum_bitrate=Bitrate.mbps(20),
routing_scope=RoutingScope.REGIONAL,
tier=RouterOutputTier.OUTPUT_100,
configuration=RouterOutputConfiguration.media_connect_flow_without_connection(
availability_zone="us-east-1a"
)
)
Output with Encryption
from aws_cdk.aws_mediaconnect_alpha import RouterSrtEncryption
# stack: Stack
# network_interface: RouterNetworkInterface
# role: iam.IRole
# secret: secretsmanager.ISecret
output = RouterOutput(stack, "EncryptedOutput",
router_output_name="encrypted-output",
maximum_bitrate=Bitrate.mbps(10),
routing_scope=RoutingScope.REGIONAL,
tier=RouterOutputTier.OUTPUT_50,
configuration=RouterOutputConfiguration.standard(
protocol=RouterOutputProtocol.srt_caller(
destination_address="203.0.113.100",
destination_port=9001,
minimum_latency=Duration.millis(200),
encryption_configuration=RouterSrtEncryption(role=role, secret=secret)
),
network_interface=network_interface
)
)
Flows
A MediaConnect flow represents a transport stream connection between a source and one or more outputs. Flows are the primary resource for transporting live video content.
Creating a Flow
The following example creates a basic MediaConnect flow with an RTP source:
# stack: Stack
flow = Flow(stack, "MyFlow",
flow_name="my-live-stream",
source=SourceConfiguration.rtp(
flow_source_name="my-source",
port=5000,
network=NetworkConfiguration.public_network("203.0.113.0/24")
)
)
Flow Sources
MediaConnect supports multiple source types for ingesting content into a flow. The examples below use NetworkConfiguration.publicNetwork() for simplicity, but all protocol-based sources can also use NetworkConfiguration.vpc() with a VPC interface for private connectivity.
The source’s
flowSourceNameanddescriptionare set on theSourceConfiguration, not onFlowSourceProps. This is because the sameSourceConfigurationis used both for a flow’s inline primary source (FlowProps.source, which has no separate props object) and for additional sources added viaFlowSource. Keeping the name on the configuration lets both be described identically.
SRT Listener Source
SRT (Secure Reliable Transport) in listener mode configures MediaConnect to listen on a specific port for incoming content. The upstream device connects to MediaConnect as a caller.
# stack: Stack
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.srt_listener(
flow_source_name="live-encoder-source",
description="Live encoder feed",
port=5000,
min_latency=Duration.millis(2000),
network=NetworkConfiguration.public_network("203.0.113.0/24")
)
)
SRT Caller Source
SRT in caller mode configures MediaConnect to connect to a remote SRT listener. Use this when the source device is listening for incoming connections rather than pushing content.
# stack: Stack
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.srt_caller(
flow_source_name="remote-source",
source_listener_address="203.0.113.50",
source_listener_port=5000,
min_latency=Duration.millis(200)
)
)
RTP Source
RTP (Real-time Transport Protocol) is a standard protocol for delivering audio and video over IP networks.
# stack: Stack
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.rtp(
flow_source_name="rtp-source",
port=5000,
network=NetworkConfiguration.public_network("203.0.113.0/24")
)
)
RTP-FEC Source
RTP with Forward Error Correction adds redundancy to recover lost packets without retransmission. Use this when contributing via RTP and you need packet recovery.
# stack: Stack
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.rtp_fec(
flow_source_name="rtp-fec-source",
port=5000,
network=NetworkConfiguration.public_network("203.0.113.0/24")
)
)
RIST Source
RIST (Reliable Internet Stream Transport) provides reliable video transport with packet recovery.
# stack: Stack
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.rist(
flow_source_name="rist-source",
port=5000,
max_latency=Duration.millis(2000),
network=NetworkConfiguration.public_network("203.0.113.0/24")
)
)
Zixi Push Source
Zixi Push uses the Zixi protocol for reliable video transport. Content is pushed to MediaConnect from a Zixi-compatible component upstream.
# stack: Stack
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.zixi_push(
flow_source_name="zixi-source",
max_latency=Duration.millis(2000),
network=NetworkConfiguration.public_network("203.0.113.0/24")
)
)
Zixi Push ports are assigned by MediaConnect: 2088 for public sources, 2090-2099 for VPC sources. See Source port assignments.
Router Source
Use a router source when the flow’s source comes from a MediaConnect Router rather than a direct connection.
# stack: Stack
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.router()
)
VPC Source
Use a VPC-based source when you need a connection between a flow and your Amazon VPC. This enables private connectivity for receiving content from on-premises equipment via AWS Direct Connect or VPN, or from other AWS services running in your VPC.
# stack: Stack
# security_group: ec2.ISecurityGroup
# subnet: ec2.ISubnet
# role: iam.IRole
vpc_interface = VpcInterface.define(
vpc_interface_name="my-vpc-interface",
role=role,
security_groups=[security_group],
subnet=subnet
)
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.rist(
flow_source_name="vpc-source",
description="VPC-based source",
port=5000,
max_latency=Duration.millis(2000),
network=NetworkConfiguration.vpc(vpc_interface)
),
vpc_interfaces=[vpc_interface]
)
Entitled Source (From Another AWS Account)
Entitlements allow you to subscribe to content from another AWS account. The entitlement is created by the content originator in their AWS account, and you import it using the entitlement ARN they provide.
# stack: Stack
# Import an entitlement from another AWS account
entitlement = FlowEntitlement.from_flow_entitlement_arn(stack, "ImportedEntitlement", "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11111111111111111111111111111111:MyEntitlement")
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.entitlement(
entitlement=entitlement
)
)
Gateway Bridge Source
Use a gateway bridge source when ingesting content from on-premises equipment through a MediaConnect gateway and bridge. Gateways define the network infrastructure that bridges use to transport video between on-premises and cloud environments.
# stack: Stack
# bridge: Bridge
# role: iam.IRole
# security_group: ec2.ISecurityGroup
# subnet: ec2.ISubnet
vpc_interface = VpcInterface.define(
vpc_interface_name="bridge-interface",
role=role,
security_groups=[security_group],
subnet=subnet
)
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.gateway_bridge(
bridge=bridge,
vpc_interface=vpc_interface
),
vpc_interfaces=[vpc_interface]
)
VPC Interfaces
VPC interfaces allow MediaConnect to send or receive content within your VPC. Create VPC interfaces using VpcInterface.define() and add them to the flow’s vpcInterfaces array. The same interface can then be referenced in sources and outputs:
# stack: Stack
# role: iam.IRole
# security_group: ec2.ISecurityGroup
# subnet: ec2.ISubnet
# Create VPC interface
vpc_interface = VpcInterface.define(
vpc_interface_name="my-vpc-interface",
role=role,
security_groups=[security_group],
subnet=subnet,
network_interface_type=NetworkInterface.ENA
)
# Add to flow and reference in source
flow = Flow(stack, "MyFlow",
vpc_interfaces=[vpc_interface], # Declare at flow level
source=SourceConfiguration.rist(
flow_source_name="vpc-source",
port=5000,
max_latency=Duration.millis(2000),
network=NetworkConfiguration.vpc(vpc_interface)
)
)
CDI and JPEG XS with EFA Interfaces
For high-performance CDI or JPEG XS workflows, use EFA (Elastic Fabric Adapter) interfaces. Note that flows can have a maximum of 1 EFA interface:
from aws_cdk.aws_mediaconnect_alpha import FmtpVideo, MediaStreamSourceConfigurationCdi
# stack: Stack
# role: iam.IRole
# security_group: ec2.ISecurityGroup
# subnet: ec2.ISubnet
efa_interface = VpcInterface.define(
vpc_interface_name="efa-interface",
role=role,
security_groups=[security_group],
subnet=subnet,
network_interface_type=NetworkInterface.EFA
)
video_stream = MediaStream.video(
media_stream_id=1,
media_stream_name="video",
video_format=MediaVideoFormat.HD_1080P,
fmtp=FmtpVideo(
exact_framerate=Framerate.FPS_29_97,
par=PixelAspectRatio.SQUARE
)
)
flow = Flow(stack, "MyCdiFlow",
flow_size=FlowSize.LARGE_4X, # Required for CDI and JPEG XS
vpc_interfaces=[efa_interface],
media_streams=[video_stream],
source=SourceConfiguration.cdi(
flow_source_name="cdi-source",
vpc_interface=efa_interface,
port=5000,
max_sync_buffer=100,
media_stream_source_configurations=[MediaStreamSourceConfigurationCdi(
encoding=Encoding.RAW,
media_stream=video_stream
)]
)
)
JPEG XS with Redundant Interfaces
JPEG XS requires exactly 2 input interfaces per media stream for redundancy. Typically one EFA and one ENA interface:
from aws_cdk.aws_mediaconnect_alpha import FmtpVideo, MediaStreamSourceConfigurationJpegXs
# stack: Stack
# role: iam.IRole
# sg1: ec2.ISecurityGroup
# sg2: ec2.ISecurityGroup
# subnet: ec2.ISubnet
efa_interface = VpcInterface.define(
vpc_interface_name="efa-interface",
role=role,
security_groups=[sg1],
subnet=subnet,
network_interface_type=NetworkInterface.EFA
)
ena_interface = VpcInterface.define(
vpc_interface_name="ena-interface",
role=role,
security_groups=[sg2],
subnet=subnet,
network_interface_type=NetworkInterface.ENA
)
video_stream = MediaStream.video(
media_stream_id=1,
media_stream_name="video",
video_format=MediaVideoFormat.UHD_2160P,
fmtp=FmtpVideo(
exact_framerate=Framerate.FPS_59_94,
par=PixelAspectRatio.SQUARE,
colorimetry=Colorimetry.BT2020,
video_range=VideoRange.FULL,
scan_mode=ScanMode.PROGRESSIVE,
tcs=Tcs.PQ
)
)
flow = Flow(stack, "MyJpegXsFlow",
flow_size=FlowSize.LARGE_4X, # Required for JPEG XS
vpc_interfaces=[efa_interface, ena_interface],
media_streams=[video_stream],
source=SourceConfiguration.jpeg_xs(
flow_source_name="jpegxs-source",
max_sync_buffer=100,
media_stream_source_configurations=[MediaStreamSourceConfigurationJpegXs(
encoding=Encoding.JXSV,
port=5000,
input_interface=[efa_interface, ena_interface], # 2 interfaces for redundancy
media_stream=video_stream
)]
)
)
Media Streams
Media streams represent individual components of your content (video, audio, ancillary data) for ST 2110 JPEG XS or CDI workflows. Create media streams using the static factory methods and add them to the flow’s mediaStreams array:
from aws_cdk.aws_mediaconnect_alpha import FmtpVideo
# stack: Stack
# Create media streams
video_stream = MediaStream.video(
media_stream_id=1,
media_stream_name="video-stream",
video_format=MediaVideoFormat.HD_1080P,
fmtp=FmtpVideo(
colorimetry=Colorimetry.BT709,
exact_framerate=Framerate.FPS_29_97,
par=PixelAspectRatio.SQUARE,
video_range=VideoRange.NARROW,
scan_mode=ScanMode.PROGRESSIVE,
tcs=Tcs.SDR
)
)
audio_stream = MediaStream.audio(
media_stream_id=2,
media_stream_name="audio-stream",
channel_order=AudioStreamOrderOptions.STANDARD_STEREO
)
# Add to flow
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.router(),
media_streams=[video_stream, audio_stream]
)
Audio Channel Order
For audio media streams, use the AudioStreamOrderOptions enum to specify the SMPTE 2110-30 channel order:
# Available channel order options
AudioStreamOrderOptions.MONO # SMPTE2110.(M)
AudioStreamOrderOptions.DUAL_MONO # SMPTE2110.(DM)
AudioStreamOrderOptions.STANDARD_STEREO # SMPTE2110.(ST)
AudioStreamOrderOptions.LTRT_MATRIX_STEREO # SMPTE2110.(LtRt)
AudioStreamOrderOptions.SURROUND_5_1 # SMPTE2110.(51)
AudioStreamOrderOptions.SURROUND_7_1 # SMPTE2110.(71)
AudioStreamOrderOptions.SURROUND_22_2 # SMPTE2110.(222)
AudioStreamOrderOptions.ONE_SDI_AUDIO_GROUP # SMPTE2110.(SGRP)
# Example with 5.1 surround
surround_audio = MediaStream.audio(
media_stream_id=3,
media_stream_name="surround-audio",
channel_order=AudioStreamOrderOptions.SURROUND_5_1
)
Media streams can be referenced in source configurations (for CDI and JPEG XS) and output configurations.
Flow Sizes
MediaConnect offers three flow sizes that determine feature support:
| Flow Size | Transport Streams | NDI | CDI / JPEG XS |
|---|---|---|---|
MEDIUM (default) |
✅ | ❌ | ❌ |
LARGE |
✅ | ✅ | ❌ |
LARGE_4X |
❌ | ❌ | ✅ |
This table maps each FlowSize to the capabilities the construct validates. For output counts, throughput limits, and other per-size details, see Flow sizes and capabilities.
The construct validates flow size constraints at synthesis time based on the source protocol and NDI configuration:
MEDIUMsupports transport stream protocols (RTP, SRT, RIST, etc.) but not NDI or CDILARGEsupports transport streams and NDI, and is required when NDI is enabledLARGE_4Xis required for CDI and JPEG XS protocols, and does not support transport streams or NDI
These are mutually exclusive — CDI/JPEG XS and NDI cannot coexist on the same flow because they require different flow sizes.
from aws_cdk.aws_mediaconnect_alpha import NdiConfig, NdiDiscoveryServerConfig, EncodingConfig, MediaStreamSourceConfigurationCdi
# stack: Stack
# ndi_vpc_interface: VpcInterfaceConfig
# efa_interface: VpcInterfaceConfig
# video_stream: MediaStream
# NDI requires LARGE, an encoding profile, and at least one discovery server
Flow(stack, "NdiFlow",
flow_size=FlowSize.LARGE,
ndi_config=NdiConfig(
ndi_state=State.ENABLED,
ndi_discovery_servers=[NdiDiscoveryServerConfig(
discovery_server_address="10.0.0.10",
vpc_interface=ndi_vpc_interface
)]
),
encoding_config=EncodingConfig(
encoding_profile=EncodingProfile.CONTRIBUTION_H264_DEFAULT
),
source=SourceConfiguration.ndi(
flow_source_name="ndi-source"
)
)
# CDI and JPEG XS require LARGE_4X
Flow(stack, "CdiFlow",
flow_size=FlowSize.LARGE_4X,
vpc_interfaces=[efa_interface],
media_streams=[video_stream],
source=SourceConfiguration.cdi(
flow_source_name="cdi-source",
vpc_interface=efa_interface,
port=5000,
max_sync_buffer=100,
media_stream_source_configurations=[MediaStreamSourceConfigurationCdi(
encoding=Encoding.RAW,
media_stream=video_stream
)]
)
)
For more information, see Flow sizes and capabilities.
Gateways
MediaConnect Gateways enable the deployment of on-premises resources for transporting live video to and from the AWS Cloud. Gateways are required for creating bridges.
Creating a Gateway
# stack: Stack
production_network = GatewayNetwork.define(
cidr_block="192.168.1.0/24",
name="production-network"
)
gateway = Gateway(stack, "MyGateway",
gateway_name="my-gateway",
egress_cidr_blocks=["10.0.0.0/16"],
networks=[production_network]
)
Importing an Existing Gateway
# stack: Stack
gateway = Gateway.from_gateway_arn(stack, "ImportedGateway", "arn:aws:mediaconnect:us-west-2:123456789012:gateway:1-XXXXXX")
Bridges
MediaConnect bridges enable you to interconnect on-premises equipment with cloud-based workflows. Bridges support both ingress (on-premises to cloud) and egress (cloud to on-premises) scenarios.
Creating a Bridge
Ingress Bridge (On-premises to Cloud)
An ingress bridge receives content from on-premises equipment and makes it available in the cloud:
from aws_cdk.aws_mediaconnect_alpha import BridgeNetworkInput, BridgeNetworkSource
# stack: Stack
production_network = GatewayNetwork.define(
cidr_block="192.168.1.0/24",
name="production-network"
)
gateway = Gateway(stack, "MyGateway",
gateway_name="my-gateway",
egress_cidr_blocks=["10.0.0.0/16"],
networks=[production_network]
)
ingress_bridge = Bridge(stack, "MyIngressBridge",
bridge_name="my-ingress-bridge",
config=BridgeConfiguration.ingress(
max_bitrate=Bitrate.mbps(10),
max_outputs=2,
network_sources=[BridgeNetworkInput(
name="on-prem-source",
source=BridgeNetworkSource(
protocol=BridgeProtocol.RTP,
network=production_network,
multicast_ip="239.1.1.1",
port=5000
)
)]
),
gateway=gateway
)
Egress Bridge (Cloud to On-premises)
An egress bridge sends content from MediaConnect flows to on-premises equipment:
from aws_cdk.aws_mediaconnect_alpha import BridgeFlowInput, BridgeFlowSource, BridgeNetworkOutput
# stack: Stack
# gateway: Gateway
# flow: Flow
# vpc_interface: VpcInterfaceConfig
# production_network: GatewayNetwork
egress_bridge = Bridge(stack, "MyEgressBridge",
bridge_name="my-egress-bridge",
config=BridgeConfiguration.egress(
max_bitrate=Bitrate.mbps(10),
flow_sources=[BridgeFlowInput(
name="cloud-source",
source=BridgeFlowSource(
flow=flow,
vpc_interface=vpc_interface
)
)],
network_outputs=[BridgeNetworkOutput(
name="on-prem-output",
output=BridgeOutputConfiguration.network(
ip_address="192.168.1.200",
port=5001,
network=production_network,
protocol=BridgeProtocol.RTP,
ttl=50
)
)]
),
gateway=gateway
)
Bridge Sources
For failover scenarios, you can add additional sources to an existing bridge using the BridgeSource construct:
# stack: Stack
# bridge: Bridge
# flow: Flow
# Add a flow source to an egress bridge (requires failover to be enabled)
additional_source = BridgeSource(stack, "AdditionalSource",
bridge_source_name="backup-source",
bridge=bridge,
source=BridgeSourceConfiguration.flow(
flow=flow
)
)
Bridge Outputs
Bridge outputs are configured as part of the bridge configuration for egress bridges. They define where content exits the bridge to on-premises equipment.
# production_network: GatewayNetwork
network_config = BridgeOutputConfiguration.network(
ip_address="192.168.1.200",
port=5001,
network=production_network,
protocol=BridgeProtocol.RTP,
ttl=50
)
named_output = {"name": "on-prem-output", "output": network_config}
Encryption
MediaConnect supports encryption for sources, outputs, and entitlements. This package provides type-safe encryption configuration structs that match the encryption requirements for different protocols.
Encryption Types
MediaConnect supports two types of encryption:
Static Key Encryption - Used for Zixi Push/Pull protocols and entitlements
SRT Password Encryption - Used for SRT Listener and SRT Caller protocols
Note: CFN exposes only static-key and srt-password for flow output encryption today; SPEKE is not currently part of the surface.
Auto-created IAM role. Every encryption struct accepts an optional role. Omit it and the consuming construct creates a scoped role for you: trust policy for mediaconnect.amazonaws.com with aws:SourceAccount + aws:SourceArn conditions (confused-deputy protection), and just enough permission to read the provided secret (including kms:Decrypt when the secret uses a customer-managed KMS key).
Providing your own role. If you supply a role, it’s used as-is — the construct does not grant it any permissions. You must grant it the necessary permissions yourself. Provide your own role when you need stricter control or a shared identity.
Trust-policy scope: flows vs. routers. When the L2 auto-creates a role, it also pins aws:SourceArn to the consuming resource:
Flows — the trust policy pins the flow ARN (
arn:...:flow:*:<flow-name>). The*wildcards the service-assigned id segment; the flow name is fixed at create time.Routers — the trust policy can only pin a wildcarded ARN (
arn:...:routerInput:*/arn:...:routerOutput:*). Router I/O ARNs use a service-generated id segment that is unknown at synth time, and using the live ARN attribute would create a CloudFormation dependency cycle (role → router → role). If you need per-resource pinning, supply your ownrolewith a trust condition that pins the exact ARN — you can compute it from the resource’srouterInputId/routerOutputIdafter first deploy and apply it on a follow-up deploy.
Static Key Encryption
Use a static-key encryption struct for Zixi protocols and entitlements. This requires an encryption algorithm (AES128, AES192, or AES256). Pass it inline where the construct asks for it:
from aws_cdk.aws_mediaconnect_alpha import StaticKeyEncryption
# stack: Stack
# flow: Flow
# role: iam.IRole
# secret: secretsmanager.ISecret
FlowEntitlement(stack, "MyEntitlement",
flow=flow,
subscribers=["111122223333"],
description="Grant partner access to live feed",
encryption=StaticKeyEncryption(
role=role,
secret=secret,
algorithm=EncryptionAlgorithm.AES256
)
)
SRT Password Encryption
SRT protocols take an encryption struct with just role and secret — no algorithm:
from aws_cdk.aws_mediaconnect_alpha import SrtPasswordEncryption
# stack: Stack
# flow: Flow
# role: iam.IRole
# secret: secretsmanager.ISecret
FlowOutput(stack, "SrtOutput",
flow=flow,
output=OutputConfiguration.srt_caller(
destination="203.0.113.100",
port=7000,
encryption=SrtPasswordEncryption(role=role, secret=secret)
)
)
Using Encryption with Sources
Apply encryption when configuring flow sources:
from aws_cdk.aws_mediaconnect_alpha import SrtPasswordEncryption, StaticKeyEncryption
# stack: Stack
# role: iam.IRole
# secret: secretsmanager.ISecret
# SRT Listener source with encryption
flow = Flow(stack, "MyFlow",
source=SourceConfiguration.srt_listener(
flow_source_name="encrypted-source",
port=5000,
network=NetworkConfiguration.public_network("203.0.113.0/24"),
decryption=SrtPasswordEncryption(role=role, secret=secret)
)
)
# Zixi Push source with encryption
flow2 = Flow(stack, "MyFlow2",
source=SourceConfiguration.zixi_push(
flow_source_name="encrypted-zixi-source",
max_latency=Duration.millis(2000),
network=NetworkConfiguration.public_network("203.0.113.0/24"),
decryption=StaticKeyEncryption(
role=role,
secret=secret,
algorithm=EncryptionAlgorithm.AES256
)
)
)
Using Encryption with Outputs
Apply encryption when configuring flow outputs:
from aws_cdk.aws_mediaconnect_alpha import SrtPasswordEncryption
# stack: Stack
# flow: Flow
# role: iam.IRole
# secret: secretsmanager.ISecret
# SRT Caller output with encryption
output = FlowOutput(stack, "EncryptedOutput",
flow=flow,
description="Encrypted SRT output",
output=OutputConfiguration.srt_caller(
destination="203.0.113.100",
port=7000,
encryption=SrtPasswordEncryption(role=role, secret=secret)
)
)
Using Encryption with Entitlements
Entitlements use static key encryption:
from aws_cdk.aws_mediaconnect_alpha import StaticKeyEncryption
# stack: Stack
# flow: Flow
# role: iam.IRole
# secret: secretsmanager.ISecret
entitlement = FlowEntitlement(stack, "MyEntitlement",
flow=flow,
description="Grant partner access to live feed",
subscribers=["111122223333"],
encryption=StaticKeyEncryption(
role=role,
secret=secret,
algorithm=EncryptionAlgorithm.AES256
)
)
Router Transit Encryption
When integrating flows with routers, use transit encryption to secure the connection between the flow and router:
from aws_cdk.aws_mediaconnect_alpha import TransitEncryption, TransitEncryption
# stack: Stack
# flow: Flow
# role: iam.IRole
# secret: secretsmanager.ISecret
# existing_router_output: RouterOutput
# Flow output to router with transit encryption
router_output = FlowOutput(stack, "RouterOutput",
flow=flow,
output=OutputConfiguration.router(
encryption=TransitEncryption(role=role, secret=secret)
)
)
# Flow source from router with transit encryption
flow_from_router = Flow(stack, "FlowFromRouter",
source=SourceConfiguration.router(
router_output=existing_router_output,
decryption=TransitEncryption(role=role, secret=secret)
)
)
Router SRT Encryption
Router outputs using SRT protocols use RouterSrtEncryption for encryption:
from aws_cdk.aws_mediaconnect_alpha import RouterSrtEncryption
# stack: Stack
# network_interface: RouterNetworkInterface
# role: iam.IRole
# secret: secretsmanager.ISecret
output = RouterOutput(stack, "EncryptedSrtOutput",
router_output_name="encrypted-srt-output",
maximum_bitrate=Bitrate.mbps(10),
routing_scope=RoutingScope.REGIONAL,
tier=RouterOutputTier.OUTPUT_50,
configuration=RouterOutputConfiguration.standard(
protocol=RouterOutputProtocol.srt_caller(
destination_address="203.0.113.100",
destination_port=9001,
minimum_latency=Duration.millis(200),
encryption_configuration=RouterSrtEncryption(role=role, secret=secret)
),
network_interface=network_interface
)
)
Note: RouterSrtEncryption is distinct from SrtPasswordEncryption (used on flow sources/outputs) — router outputs use a simpler CFN shape without a keyType discriminator.
CloudWatch Metrics
Flows and Bridges expose CloudWatch metric helpers for monitoring. You can create alarms and dashboards using these metrics:
# flow: Flow
# stack: Stack
# Create a CloudWatch alarm on source bitrate
alarm = flow.metric_source_bitrate().create_alarm(stack, "LowBitrate",
threshold=1000000,
evaluation_periods=1
)
# Monitor unrecovered packets
flow.metric_source_not_recovered_packets().create_alarm(stack, "PacketLoss",
threshold=100,
evaluation_periods=2
)
# Track total packets with custom options
total_packets = flow.metric_source_total_packets(
statistic="sum",
period=Duration.minutes(5)
)
Flow metrics
metricSourceBitrate()- Bitrate of content ingested into the flow (average)metricSourceNotRecoveredPackets()- Packets lost in transit that were not recovered by error correction (sum)metricSourceTotalPackets()- Total packets received by the flow sources (sum)metricSourceSelected()- Indicates which source is being used under Failover mode (max; 1 = active, 0 = standby)metricSourceConnected()- Source connection state for Zixi, SRT, and RIST (min; 1 = connected, 0 = disconnected)metricSourceDisconnections()- Number of times the source transitioned from connected to disconnected (sum)metricSourceDroppedPackets()- Packets lost before any error correction took place (sum)metricSourcePacketLossPercent()- Percentage of packets lost during transit, even if they were recovered (average)metricSourceRoundTripTime()- Round-trip time to the source for RIST, Zixi, and SRT (average, milliseconds)metricSourceJitter()- Current network jitter of the source (average, milliseconds)metric(metricName)- Create a custom metric by name
Bridge metrics
Bridge metrics are dimensioned by BridgeARN. The underlying CloudWatch metric name is chosen automatically based on whether the bridge is ingress or egress.
metricSourceBitrate(bridgeSourceName)- Bitrate of a specific bridge source (average)metricSourcePacketLossPercent(bridgeSourceName)- Percentage of packets lost on a specific bridge source (average)metricFailoverSwitches()- Total number of times the bridge switches between sources underFAILOVERfailover mode (sum)metric(metricName)- Create a custom metric by name
Router Input metrics
Router input metrics are dimensioned by RouterInputARN.
metricBitrate()- Bitrate of the router input’s payload (average)metricNotRecoveredPackets()- Packets lost in transit that were not recovered by error correction (sum)metricTotalPackets()- Total number of packets received by the router input (sum)metricConnected()- Connection state for SRT sources (min; 1 = connected, 0 = disconnected)metricContinuityCounterErrors()- Continuity counter errors in the transport stream (sum)metricLatency()- Recovery latency of the input stream for RIST, SRT, and RTP-FEC (average, milliseconds)metricFailoverSwitches()- Total times the router input switched sources under Failover mode (sum)metric(metricName)- Create a custom metric by name
Router Output metrics
Router output metrics are dimensioned by RouterOutputARN.
metricBitrate()- Bitrate of the router output’s payload (average)metricTotalPackets()- Total number of packets sent by the router output (sum)metricConnected()- Connection state for SRT outputs (min; 1 = connected, 0 = disconnected)metricArqRequests()- Retransmitted packets requested through ARQ for RIST and SRT outputs (sum)metric(metricName)- Create a custom metric by name
Gateway metrics
Gateway metrics are dimensioned by GatewayARN. Pass extra dimensions such as NetworkName, InstanceId, or BridgeSourceName via props.dimensionsMap to narrow to a specific network, appliance, or bridge source.
metricEgressBridgeTotalPackets()- Total packets sent from egress bridges hosted on the gateway (sum)metricEgressBridgeDroppedPackets()- Packets dropped by egress bridges hosted on the gateway (sum)metricIngressBridgeTotalPackets()- Total packets received by ingress bridges hosted on the gateway (sum)metricIngressBridgeDroppedPackets()- Packets dropped by ingress bridges hosted on the gateway (sum)metric(metricName)- Create a custom metric by name (e.g.IngressBridgeBitRate,EgressBridgeBitRate,IngressBridgeSourcePacketLossPercent)
Pair the total + dropped helpers to build a dropped-packet percentage chart — for example, divide metricEgressBridgeDroppedPackets() by metricEgressBridgeTotalPackets() in a math expression.
All metrics support standard CloudWatch metric options for customizing period, statistic, and dimensions.
Public CIDR warnings
Several constructs accept CIDR ranges that determine who can contribute content or pull outputs. Passing an open range (0.0.0.0/0 or any /0 prefix) makes the resource reachable from anywhere on the public internet, which is rarely what you want. The module emits synthesis-time warnings when it detects an open range on:
GatewayProps.egressCidrBlocksNetworkConfiguration.publicNetwork(cidr)used on flow sourcescidrAllowListon Zixi Push / Zixi Pull / SRT Listener flow outputsRouterNetworkConfiguration.publicNetwork({ cidr })
Restrict each range to the narrowest set of addresses that actually need access.