awscdk-construct-input-switch-scheduler
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

awscdk-construct-input-switch-scheduler

View on Construct Hub

CDK Construct for scheduling input switch of MediaLive

  • Input:
    • MediaLive channel id
    • List of input attachements to be switched in a toggle manner
    • Switch interval (minutes)
  • Output:
    • Lambda function for calling MediaLive schedule API
    • EventBridge rule for periodically invoking the function

Install

NPM

Usage

import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { LiveChannelFromMp4 } from 'awscdk-construct-live-channel-from-mp4-file';
import { InputSwitchScheduler } from 'awscdk-construct-input-switch-scheduler';

export class ExampleStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    // Create a live channel (MediaLive + MediaPackage)
    const {eml, empv1: emp} = new LiveChannelFromMp4(this, 'LiveChannelFromMp4', {
      sourceUrl: [
        's3ssl://example_bucket/test-1.mp4',
        's3ssl://example_bucket/test-2.mp4',
      ],
      autoStart: true,
    });

    // Perform input switch every 15 minutes
    new InputSwitchScheduler(this, 'InputSwitchScheduler', {
      channelId: eml.channel.ref,
      inputAttachments: eml.channel.inputAttachments?.map(({inputAttachmentName}) => inputAttachmentName),
      intervalInMinutes: 15,
    });

    // Print MediaPackage endpoint URL (HLS)
    new CfnOutput(this, "MediaPackageEndpointURL", {
      value: emp.endpoints.hls.attrUrl,
      exportName: "MediaPackageEndpointURL",
      description: "MediaPackage endpoint URL",
    });
  }
}

Package Sidebar

Install

npm i awscdk-construct-input-switch-scheduler

Weekly Downloads

83

Version

0.0.4

License

MIT

Unpacked Size

7.77 MB

Total Files

3295

Last publish

Collaborators

  • kuu