Amazon Cloudformation

This tutorial shows you how use Cloudformation to integrate Unified Streaming launched on an Amazon EC2 instance with S3 Storage and Amazon CloudFront to deliver on-demand HTTP streaming sessions globally.

CloudFront can be used for fast streaming of audio and video at scale because it stores the streaming data in its global network of edge locations. When a player application requests a stream from your Unified Streaming server running on an Amazon EC2 instance origin, CloudFront automatically routes the request to the optimal edge location so that the stream is delivered with the best possible performance.

Using the CloudFormation script different types of instances to run Unified Streaming can be selected as well as AutoScaling.

This tutorial is also avialable as Cloudformation tutorial.

Creating an Amazon Web Services Account and Keypair

If you already have an Amazon Web Services (AWS) account, see Creating an Amazon EC2 Key Pair. If you don't already have an AWS account, use the following procedure to create one.

Note

When you create an account, AWS automatically signs up the account for all services. You're charged only for the services that you use.

To create an AWS account

  1. Go to http://aws.amazon.com, and click Sign Up.
  2. Follow the on-screen instructions.

Creating an AWS CloudFormation Stack for On-demand Streaming

The following procedure uses an AWS CloudFormation template to create a stack that launches the AWS resources required for streaming, including Amazon EC2 instances, using an existing Amazon S3 bucket, Elastic Load Balancer, Amazon CloudWatch alarms and an Amazon CloudFront distribution.

Download: autoscaling-vod-http-streaming--with-existing-s3-bucket.cft

There are no AMI's referenced in the cloudformation template yet (the RegionMap section), but you can fill in those from the AWS Marketplace (click 'Manual Launch to see the IDs).

If you're interested in using other templates, for instance creating a new S3 bucket or use your own license - please send us an email at Unified Streaming Contact.

When you no longer need to stream, delete the stack that you created to avoid charges for the AWS resources. The one exception to this is that your Amazon S3 buckets will never be deleted since they potentially contain your media asset library.

To create an AWS CloudFormation stack for on-demand streaming

Go to your AWS console and create an S3 bucket and upload your content (alternatively, you can use an existing bucket with existing content).

1 - Click on the EU (Ireland) Region console (similar for other Regions).

2 - If you are not already signed in to the AWS Management Console, sign in when prompted.

3 - Optional: Change the value of the Stack Name field. The stack name must not contain spaces, and it must be unique within your AWS account.

../../../_images/create.png

4 - Select the template location: use an existing one, upload one or use a sample one.

5 - Optional: To configure SNS notification, to specify how long you're willing to wait for the stack to be created, and to choose whether to roll back changes if stack creation fails, check the Show Advanced Options checkbox, and specify the applicable values.

6 - Click Continue, and the Specify Parameters page of the Create Stack wizard appears.

../../../_images/bucket.png

7 - In the AmazonEC2KeyPair field, enter the name of an Amazon EC2 key pair in the region in which you want to create the stack for video streaming. The key pair must be associated with the account that you're currently logged on with. If you created a key pair when you performed the procedure in Creating an Amazon EC2 Key Pair, enter the name of that key pair.

8 - In the MaxInstanceNum field, if you wish to override the default value, enter the maximum number of EC2 instances you want to have running at any given time.

9 - Enter a valid S3 bucket name for AmazonS3BucketName. (The name of a bucket you own.)

10 - In the MinInstanceNum field, if you wish to override the default value, enter the minimum number of EC2 instances you want to have running at any given time.

11 - In the InstanceType field, enter the Amazon EC2instance type you want to use, and click Continue. The default value is m1.large. For more information about Amazon EC2 instance types, see Available Instance Types.

12 - Optional: In the next dialog, add the key/value pairs (and tags) for any tags you plan to use. Click Continue.

13 - Review the settings for the stack. When you're satisfied with the settings, click Continue.

14 - Dismiss the stack creation dialog by clicking Close.

Your stack may take several minutes to create. To track the progress of the stack creation, select the stack, and click the Events tab in the bottom frame. If AWS CloudFormation cannot create the stack, the Events tab lists error messages.

When your stack is ready, the status for the stack changes to CREATE_COMPLETE.

../../../_images/complete.png

Playing the On-demand Stream using a Web Application

When your stack is created, click the Outputs tab, which displays the stack creation outputs. You will use these values later in the process.

../../../_images/outputs.png

If you have placed your content inside a folder within the bucket, include that folder in the media file path.

../../../_images/url.png

In other words, replace the string '<media-file-path-excluding-bucket-name-but-including-the-media-filename>' with the path and filename you want to stream

The content itself has to be open/downloadable by 'everyone'. If you do no want to allow this you can follow Amazon S3 with authorization.

To play DASH streams via CloudFront

Step 1, 2 and 3 similar as with Smooth Streams.

4 - Copy the value of the DASHManifest key.

5 - Update the URL with the correct path of the asset in Amazon S3. For example if your bucket name was unifiedhttpstreaming-s3bucket-123abc4 and your media filename is nasa_msl_launch.mp4, then this URL will become

http://d123xyz.cloudfront.net/unifiedhttpstreaming-s3bucket-123abc4/nasa_msl_launch.mp4/.mpd

To play Apple HLS streams via CloudFront

Step 1, 2 and 3 similar as with Smooth Streams.

4 - Copy the value of the HLSManifest key.

5 - Update the URL with the correct path of the asset in Amazon S3. For example if your bucket name was unifiedhttpstreaming-s3bucket-123abc4 and your media filename is nasa_msl_launch.mp4, then this URL will become

http://d123xyz.cloudfront.net/unifiedhttpstreaming-s3bucket-123abc4/nasa_msl_launch.mp4/.m3u8

To play Smooth Streams via CloudFront

1 - Open the AWS CloudFormation console.

2 - Select the checkbox for the stack for on-demand HTTP streaming.

3 - In the bottom pane of the AWS CloudFormation console, click the Outputs tab.

4 - Copy the value of the SmoothManifest key.

5 - Update the URL with the correct path of the asset in Amazon S3. For example if your bucket name was unifiedhttpstreaming-s3bucket-123abc4 and your media filename is nasa_msl_launch.mp4, then this URL will become

http://d123xyz.cloudfront.net/unifiedhttpstreaming-s3bucket-123abc4/nasa_msl_launch.mp4/manifest

To play Adobe HDS stream via CloudFront

Step 1, 2 and 3 similar as with Smooth Streams.

4 - Copy the value of the HDSManifest key.

5 - Update the URL with the correct path of the asset in Amazon S3. For example if your bucket name was unifiedhttpstreaming-s3bucket-123abc4 and your media filename is nasa_msl_launch.mp4, then this URL will become

http://d123xyz.cloudfront.net/unifiedhttpstreaming-s3bucket-123abc4/nasa_msl_launch.mp4/.f4m

Deleting an AWS CloudFormation Stack for On-demand Streaming

When your need for streaming is over, you may delete the stack that you have created. This deletes the AWS resources that were created and stops the on-demand charges for the resources. Please note that the Amazon S3 bucket associated with this stack will not be deleted since it may potentially contain your media assets.

To delete an AWS CloudFormation stack for on-demand streaming

1 - Open the AWS CloudFormation console.

2 - In the upper-right corner of the console, select the region in which the stack is running.

3 - Select the checkbox for the stack, and then click Delete Stack.

4 - Click Yes, Delete to confirm.

5 - To track stack-deletion progress, select the checkbox for the stack and click the Events tab in the bottom frame.