This workflow will create buckets and an API to manage VOD content with AWS.
An input bucket will be created and used to store raw video content. Once a file is uploaded to this bucket, a Lambda function will be triggered and it will create a MediaConvert job to transcode the video. The transcoded video will then be stored into an output bucket. API Gateway will let you make API requests to get the list of transcoded videos available in the output bucket.
Features:
- API to perform CRUD operations on the content
- S3 tagging
- Cognito integration
- Metadata stored in DynamoDB
- Easy configuration
- Easy install - one command to deploy the full stack and the s3 triggers
- m3u8 support
AWS Elemental MediaConvert is used to transcode raw files for VOD
API Gateway will create endpoint to link a lambda function to them
A Lambda function will be created for each API endpoint (managed by API Gateway) and another Lambda function will be used to create transcoding jobs with MediaConvert
CloudFront is used to serve private content from S3 and cache content
All the steps requires you to have AWS CLI installed.
It also needs your credentials to be set inside ~/.aws/credentials
A bucket will be needed for Serverless framework. This bucket will be used to store data during deployment.
The other buckets will be created during deployment.
Then, you can create an S3 Bucket (in the same region where you want to deploy your API), you can call it vod-workflow-serverless-dev
for example.
A CloudFront key pair is needed for the presigned URLs generation. Instructions are available here.
You will need to save the key pair ID and also the private key, they will be used in the next section for the configuration.
Instructions are available here to install NodeJS and NPM.
Instructions are available here to install Serverless.
Go to your AWS Console and create an access key for Serverless by following this tutorial. You have details on how to use your access key with Serverless below the tutorial.
A configuration file named config.json
is available to customize this workflow. Two modifications are mandatory (see below), once you have made them, you can rename the other values in this configuration file based on your needs.
You need to set as deployment bucket the name of the bucket created above (vod-workflow-serverless-dev
), so Serverless can push content to this bucket for deployment. Also, you can change the region you want to deploy this workflow.
First, you will need to add information about the key pair generated above into the configuration file:
- “keyPairId” must be the generated key pair ID
- “privateKey” is the content of the private key that you have downloaded (Note: Each new line should be replaced by \n, so the private key can be stored as one single line)
Then, you will have to do a first deployment so Serverless can setup everything. Once you have done the first deployment, you will need to go to the AWS Console and search for the CloudFront distribution created with this workflow. A base URL will be displayed, this value needs to be stored as “baseURL” in configuration file.
- Install required libraries
$> npm install
- You can now deploy the workflow with the following command:
$> serverless deploy
$> serverless s3deploy # This command will add events notification support to trigger Lambda for transcoding
A detailed documentation about API is available here
Users are managed using AWS Cognito.
Two Cognito users pools are used:
vod-workflow-user-pool-users
: For every endpointsvod-workflow-user-pool-admins
: For POST and DELETE requests
- Get CloudFront distribution automatically
- AWS Step Functions option for easy interface for operators
- Feel free to send your suggestions at [email protected]