DEV Community

Cover image for Hosting an Open Source WebRTC as a Service with AWS CDK - Part 1
Cristian Paul Peñaranda Rojas for AWS Community Builders

Posted on • Updated on

Hosting an Open Source WebRTC as a Service with AWS CDK - Part 1

Hostedjanus is an open source software as a service platform that host the Janus WebRTC Server ©.

The end goal from these posts is to show you how to set up a WebRTC gateway into a SaaS service offering using AWS Cloud Tools, while highlighting how the uses of these technologies simplifies the making of a SaaS offering a lot.

In this part, I'll cover building the Janus image and getting it ready for later orchestration and development of the SaaS REST API.

Most of the sections of the Dockerfile are for installing libraries and requirements before compiling the Janus source code 1.

Port 80 and 7088 are exposed, they would help us to administrate and use as consumer the Janus REST API later.

COPY run.sh /run.sh

EXPOSE 80 7088

CMD  /bin/bash /run.sh
Enter fullscreen mode Exit fullscreen mode

On a separate script, run.sh 2 it's where the initial configuration happens when the container is going up, including:

  • Enabling NAT
  • Setting Public IP value
  • RTP Port range (soft limit)
  • Enabling Admin API and setting a default password

With this, what remain is to create the AWS resources needed to get the image in to ECS Cluster using CDK 3 we will create:

  • VPC
  • Security groups
  • Task definition (including health check)
  • Service definition
  • Docker image management (Asset)

With this setup, every time you hit from the CLI de cdk deploy command if necessary it will build the Docker image locally and upload it again.

The health check is very important as it will work as long as the run.sh script does it job.

If we want to check if Janus is responding, we can get the server info 4 via REST.

$ curl  XX.XXX.XX.XXX:8088/janus/info -s | jq .name
"Janus WebRTC Server"

Enter fullscreen mode Exit fullscreen mode

The Above IP can be obtained from the ECS Cluster Service task.

Image description

This concludes Part 1, in the next post I'll cover how to implement a REST Web API for getting Janus WebRTC Server © on demand.

If you want to give it a try, the CDK code for this first part is available at Hostedjanus GitHub 5. You can deploy cdk deploy and delete cdk destroy anytime you want.

Discussion (0)