0.0.30 • Published 14 days ago

awscdk-mediatailor-cloudfront-construct v0.0.30

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days ago

awscdk-mediatailor-cloudfront-construct

CDK Construct to associate MediaTailor config with CloudFront distribution

View on Construct Hub

This CDK Construct consists of two resources:

  • MediaTailor playback configuration
  • CloudFront distribution

And then associates them by updating MediaTailor's settings:

  • Content Segment Prefix: https://{CloudFront hostname}/out/v1/{MediaPackage endpoint ID}
  • Ad Segment Prefix: https://{CloudFront hostname}

Install

NPM

Usage

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { MediaTailorWithCloudFront } from 'awscdk-mediatailor-cloudfront-construct';

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

    const videoContentSourceUrl = 'https://xxxx.mediapackage.us-east-1.amazonaws.com/out/v1/yyyy/index.m3u8';
    const adDecisionServerUrl = 'https://example-ad-server/vast';
    const slateAdUrl = 'https://example-bucket.s3.us-east-1.amazonaws.com/slate.mp4';

    // Create MediaTailor with CloudFront
    const res = new MediaTailorWithCloudFront(this, 'MediaTailorWithCloudFront', {
      videoContentSourceUrl, // (required) The origin URL
      adDecisionServerUrl, // (optional) The ad decision server URL
      slateAdUrl, // (optional) The URL of the slate video file
      // configurationAliases, // (optional) The configuration aliases used by MediaTailor
      // adDecisionFunction, // (optional) Instead of adDecisionServerUrl, you can specify a Lambda function that returns VAST/VMAP
      // adDecisionFunctionApiPath, // (optional) The API path (including query strings) used by MediaTailor for invoking the Lambda function
      // skipCloudFront, // (optional) Skip the CloudFront setup (default = false)
    });

    // You can access MediaTailor playback configuration attributes via `emt.config`
    new cdk.CfnOutput(this, "SessionInitializationPrefix", {
      value: res.emt.config.attrSessionInitializationEndpointPrefix,
      exportName: cdk.Aws.STACK_NAME + "SessionInitializationPrefix",
      description: "MediaTailor's session initialization prefix",
    });

    // You can access CloudFront distribution attributes via `cf.distribution`
    new cdk.CfnOutput(this, "CloudFrontHostname", {
      value: res.cf.distribution.distributionDomainName,
      exportName: cdk.Aws.STACK_NAME + "HLSPlaybackPrefix",
      description: "CloudFront distribution's host name",
    });
  }
}
0.0.30

14 days ago

0.0.29

14 days ago

0.0.28

1 month ago

0.0.26

1 month ago

0.0.27

1 month ago

0.0.25

1 month ago

0.0.24

1 month ago

0.0.23

2 months ago

0.0.22

2 months ago

0.0.21

2 months ago

0.0.20

2 months ago

0.0.19

2 months ago

0.0.17

2 months ago

0.0.18

2 months ago

0.0.10

2 months ago

0.0.11

2 months ago

0.0.12

2 months ago

0.0.13

2 months ago

0.0.14

2 months ago

0.0.15

2 months ago

0.0.9

2 months ago

0.0.16

2 months ago

0.0.8

2 months ago

0.0.5

2 months ago

0.0.7

2 months ago

0.0.6

2 months ago

0.0.3

2 months ago

0.0.4

2 months ago

0.0.1

2 months ago

0.0.0

2 months ago