awscdk-construct-lambda-function-for-inserting-scte
AWS CDK Construct for scheduling SCTE-35 events using the MediaLive schedule API
- Input:
- MediaLive channel id
- SCTE event duration (seconds)
- Repeat interval (minutes)
- Output:
- Lambda function for calling MediaLive schedule API
- EventBridge rule for periodically involing the function
Install
Usage
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { ScteScheduler } from 'awscdk-construct-lambda-function-for-inserting-scte';
export class ExampleStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const {schedule, lambda} = new ScteScheduler(this, 'ScteScheduler', {
channelId: '12345',
scteDurationInSeconds: 60,
intervalInMinutes: 2,
});
new AwsCustomResource(this, 'EnableEventBridgeRule', {
onCreate: {
service: 'EventBridge',
action: 'EnableRule',
region: cdk.Aws.REGION,
parameters: {
EventBusName: 'default',
Name: schedule.rule.ruleName,
},
physicalResourceId: PhysicalResourceId.of(`EnableRule-${Date.now().toString()}`),
},
policy: AwsCustomResourcePolicy.fromSdkCalls({
resources: AwsCustomResourcePolicy.ANY_RESOURCE,
}),
});
new cdk.CfnOutput(this, "LambdaFunction", {
value: lambda.func.functionArn,
exportName: cdk.Aws.STACK_NAME + "LambdaFunction",
description: "Lambda function ARN",
});
new cdk.CfnOutput(this, "EventBridgeRule", {
value: schedule.rule.ruleArn,
exportName: cdk.Aws.STACK_NAME + "EventBridgeRule",
description: "EventBridge rule ARN",
});
}
}