| Date | Update Notes |
|---|---|
| 2020-06-08 | Added Live switching functionality into the Dashboard |
| 2020-06-15 | Added SCTE35 insertion functionality into the Dashboard |
| 2020-08-17 | Added support for Elemental Link input, and static file (slate) switching on the LIVE tab |
This repo contains all of the tools and instructions necessary for you to deploy and build an HTML dashboard, capable of interfacing with, and creating a playout schedule for AWS Elemental MediaLive. This is what the finished product will look like!
These instructions assume that:
- You've already created an AWS account
- Your IAM user has full administrator access
- You have sample content in an S3 bucket that has been sanitized to MP4 format
- Other assumptions will be called out in the instructions
The architecture utilizes these AWS Services:
- AWS Elemental MediaLive (this is the playout engine)
- AWS Elemental MediaPackage (this service packages the OTT stream and acts as an origin)
- AWS Elementa MediaConvert (this service is responsible for reliably distributing transport stream video)
- Amazon S3 (this storage service will be the origin for our playout assets)
- Amazon EC2 (this virtual compute service will be where we host our dashboard site and transmux the output of MediaConnect to RTMP for display)
- Amazon API Gateway
- AWS Lambda
- IAM
Follow the below instructions to deploy each component in the workflow...
-
IAM Role Configuration
-
AWS Lambda Functions Configuration
-
Amazon API Gateway Configuration
-
EC2 Deployment
-
EC2 Server Configuration with API Endpoints
-
AWS Elemental MediaPackage Configuration
-
AWS Elemental MediaConnect Configuration
-
AWS Elemental MediaLive Configuration
We need to create a lot of Service roles in order for the AWS Services to work as expected. The list of Roles include:
-
AWS Lambda Role - Attach polices for APIGatewayInvoke, MediaLive, ElasticSearch, and S3 access
-
AWS Elemental Live Role - Attach policies for S3, SSM, MediaPackage, EC2, CloudWatch, MediaStore, MediaConnect, VPC
-
AWS Elemental MediaConnect Role - Attach policies for VPC access
-
Amazon EC2 (optional) - Attach policies for S3, and ElasticSearch access
All of the below Roles will be added using the AWS Console, so log into your account and navigate to the IAM
-
In the IAM Console, select Roles from the navigation pane and then the 'Create Role' button
-
Under 'Trusted entity', select AWS Service, then select 'Lambda' from the available services displayed. Click Next: Permissions
-
Search for 'S3ReadOnlyAccess', tick the box to the left of the result to add this policy to the role. Then clear the search box and search for 'AmazonAPIGatewayInvokeFullAccess', tick the box to the left of the result, then select Create Policy, this will open a new tab to create a custom policy.
-
Under Service, search for and select 'MediaLive', under Actions select 'All MediaLive Actions'. Under Resources select 'All resources', then select Review Policy
-
Call the policy 'MediaLiveFullAccess', then select Create policy
-
Go back to the Create role tab in your browser, select the refresh button and then tick the box to the left of the result
-
Click on Next: Tags
-
Click on Next: Review
-
In the Role name field, enter 'AWSLambdaAccessToS3AndEML'
-
Select Create role
The best way to create a MediaLive role with the right policies is to first get MediaLive to create a role automatically. We will then go and edit the role to contain what we need.
-
In the AWS console, search for MediaLive and select the result to go to the MediaLive Console.
-
Click on Create Channel, don't worry, we're not actually going to create the channel
-
Under Create Channel, click on Channel and input details
-
Click on Create role from template, then the Create IAM role button
- You will see a role has been successfully created
-
Don't go any further in the channel configuration, instead, navigate to the IAM console.
-
Go to the Roles section and search for the role that MediaLive just created, it should be called 'MediaLiveAccessRole'. Click on the returned result.
- In the Permissions tab, click on the MediaLiveCustomPolicy, then select the Edit Policy button.
- In the Policy editor, select the JSON tab, then paste the contents of the below json block into the editor.
Policy json code block:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"mediastore:ListContainers",
"mediastore:PutObject",
"mediastore:GetObject",
"mediastore:DeleteObject",
"mediastore:DescribeObject"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams",
"logs:DescribeLogGroups"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"mediaconnect:ManagedDescribeFlow",
"mediaconnect:ManagedAddOutput",
"mediaconnect:ManagedRemoveOutput"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:describeSubnets",
"ec2:describeNetworkInterfaces",
"ec2:createNetworkInterface",
"ec2:createNetworkInterfacePermission",
"ec2:deleteNetworkInterface",
"ec2:deleteNetworkInterfacePermission",
"ec2:describeSecurityGroups"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"mediapackage:DescribeChannel"
],
"Resource": "*"
}
]
}-
Select Review Policy
-
Select Save Changes
-
In the IAM Console, select Roles from the navigation pane and then the 'Create Role' button
-
Under 'Trusted entity', select AWS Service, then select 'EC2' from the available services displayed (we have to change the trusted entity to MediaConnect after the role is created). Click Next: Permissions
-
Search for 'AmazonVPCFullAccess', tick the box to the left of the result to add this policy to the role.
-
Click on Next: Tags
-
Click on Next: Review
-
In the Role name field, enter 'MediaConnectFullAccessToVPC'
-
Select Create role
Now the role has been created with the correct policy, we need to change the trusted identity from ec2 to mediaconnect.
- In the IAM Console, select Roles from the navigation pane and then search for the role just created in the search box 'MediaConnectFullAccessToVPC'. Click on the result displayed in the table
-
In the Role Summary page, select the Trust Relationships tab, then Edit Trust Relationship
-
In the policy document, replace 'ec2' with 'mediaconnect'
- Select Update Trust Policy
[under construction... not needed for this deployment anyway]
We will create a Lambda function in this section. Get the function code from the /lambdafunctions/workshop directory in this repository, it is called playout_Functions.zip
-
Login to the AWS Management Console
-
Navigate to the AWS Lambda Console
-
Under Functions, select Create Function
-
Select Author from scratch
-
Give the Function a Name, please call it :
playout_Functions -
Use Code Runtime :
Python 3.7 -
Under Permissions, select 'Use an existing role', and then choose the role created earlier : AWSLambdaAccessToS3AndEML
-
Select Create Function
-
Under the Function Code section, change the 'Code entry type' to Upload a zip file. Select the Upload button and browse to the ZIP file for this function.
- After the code has imported, scroll down to the Basic Settings section, press the 'Edit' button and change the Timeout value to 2 minutes.
- Select the Save button and move on to the next section.
-
Navigate to the /apigatewayjson directory of this repo.
-
Open the 'playout-eng-swagger-apigateway-playout_function.json' file in your favorite text editor (Notepad++, TextWrangler, etc...). Do a Find and Replace on all occurrences of : '112233445566' Replace this number with your AWS account number that is hosting the AWS Lambda Functions (without hyphens '-'). There should be 2 occurrences.
You can find your account number in the AWS console, under the account drop-down menu
In the below screenshot I'm doing a Find & Replace with my account number: 123412341234. Do the same for yours
No need to save the file, just do a Ctrl+A or copy all command to copy the contents of the json file to your clipboard
-
Login to the AWS Management Console
-
Navigate to the Amazon API Gateway Console
-
Select Create API
-
Under API Type, choose to Import a REST API
-
Under Choose the protocol, select REST, and under Create new API, select Import from Swagger or Open API 3. Then paste the contents from the edited 'playout-eng-swagger-apigateway-playout_function.json' file
-
Select Import
-
To verify that the API endpoints correspond to your AWS Lambda function, click on the PUT or GET 'Method' below the Resource, then select the AWS Lambda function hyperlink on the right hand side of the Execution flow. Clicking the link should open up your Lambda function.
-
In order for API Gateway to be granted access to execute the AWS Lambda function, you have to edit and save the function in the Integration Request execution settings. Under Resources click on the GET or PUT Method for the Resource, then select Integration Request. Click on the pencil next to the Lambda Function field, and then press the tickbox. Then click OK. API Gateway now has permissions to execute the Lambda function for this Method.
-
Repeat the above step for all API Methods that exist in the Resource (GET, PUT, DELETE, POST)
-
To deploy the API, click on the root slash, then the Actions button, followed by Deploy API
- In the Deploy API options, choose to create a new 'Deployment Stage', call it 'eng'. Optionally, give the stage a description.
- Click on Save Changes and take note of the Invoke URL, this is the API endpoint that's needed in the EC2 Server Configuration section of these instructions.
-
Login to the AWS Management Console
-
Navigate to the EC2 Console
-
Click Instances, then Launch Instance
- Select the Amazon Linux 2 AMI (this should be shown in the 'Quick Start' tab)
- For Instance Type, choose t2.large or equivalent, then select Next: Configure Instance Details
Assumption: You are using the default VPC or a custom VPC that you have attached an Internet Gateway to. Remember, this Virtual Machine will need Internet access...
-
Number of Instances : 1
-
Network : [Select your VPC]
-
Subnet : Choose a Subnet that has a route to the Internet
-
Auto-assign Public IP : Enable
-
Expand the Advanced Details section. In the 'User Data' field, paste in the below text:
#!/bin/bash
sudo yum -y install git
sudo git clone https://github.com/scunning1987/channelPlayoutManagementUI.git
cd channelPlayoutManagementUI
sudo /bin/bash install-amazonlinux.shThis is what is will look like...
Leave all other fields in this step of the wizard to default
-
Click Next: Add Storage
-
Optional : If you want your EBS volume to be encrypted, select the Encryption drop-down and choose the default option
-
Click Next: Add Tags
-
Click Add Tag
-
In the Key field, enter 'Name', in the Value field, enter the name for this server. For Example : Channel_Playout_Control. This name will appear in the EC2 console when it is deployed
-
Click Next: Configure Security Group
-
Click the 'Create new security group' button
-
In the Security group name field, enter 'channel-playout-sg'
-
In the Description field, enter 'security group for channel playout host'
-
Click the Add Rule button to display a new row, here are the required rules:
| Type | Protocol | Port Range | Source | Description |
|---|---|---|---|---|
| SSH | TCP | 22 | Custom: 0.0.0.0/0 | SSH access |
| HTTP | TCP | 80 | Custom: 0.0.0.0/0 | HTTP Web Access |
| Custom TCP | TCP | 1935 | Custom: 0.0.0.0/0 | RTMP Access |
| Custom TCP | TCP | 20000 | Custom: 0.0.0.0/0 | RTP Stream From MediaConnect |
| Custom UDP | UDP | 20000 | Custom: 0.0.0.0/0 | UDP Stream From MediaConnect |
For extra security, you can specify the source IP address ranges that can communicate with this EC2 instance. You can edit security group rules at any time after creation, and any changes will take effect immediately.
Here's what your Security Group should look like

-
Click Review and Launch
-
Click Launch
-
You will be prompted to select or create a new key pair (for ssh access). Select Create a new key pair from the drop-down menu and give the key file a suitable name: ec2-us-west-2
-
Download the key pair, then select Launch Instances
-
You will get a success message saying that 'Your instances are now launching'. Select the View Instances button to return to the EC2 dashboard in the Instances section.
Now our EC2 Web & RTMP Server is up and running! Please take note of some information that we'll need later:
| Private IP | Public DNS or IPv4 IP |
|---|---|
| 172.1.2.3 | ec2-52-24-130-125.us-west-2.compute.amazonaws.com |
Note: If you turn off your instance and then turn it back on, it will be assigned a new Public IPv4 and DNS address. The private IP address does not change, however.
After a few minutes you can validate that the server had all its applications installed successfully by trying to load the UI in your browser:
http://[Public DNS or IPv4 IP]/mcr/softpanel.html
Example: http://ec2-52-24-130-125.us-west-2.compute.amazonaws.com/mcr/softpanel.html
For simplicity, a configuration dashboard is available for you to enter your target URL's, including API Gateway endpoint, and HLS endpoint.
Using your EC2's public IP or FQDN, navigate to this page in your browser (replace the IP below with your public address):
Example: http://12.23.34.45/dashboard-master.html
Click the Update All button once you've filled out all of the details
Note: you will need to refresh your browser for any of these changes to take effect on your dashboard page, and you may even require a cache clear
Optional
Optional
Optional






























