Try Live Demo

In this blog post, we will tell you how to install the Ant Media Server cluster in a short time by uploading the template file via CloudFormation which is prepared for AWS. First, let's explain what the CloudFormation is about.

What is CloudFormation?

AWS CloudFormation is a configuration orchestration tool that allows you to codify your infrastructure to automate your deployments and its templates are JSON or YAML-formatted text files. In short, CloudFormation is an AWS service that allows you to describe and provision your AWS infrastructure using a simple text file.

aws cloudformation

CloudFormation Installation For Scaling Ant Media Server

Now let's start on to the CloudFormation setup and continue step by step.

1. Firstly, let's subscribe to the Ant Media Server on the Amazon Marketplace. Open the link: https://aws.amazon.com/marketplace/pp/B07569Y9SJ/ then please proceed by clicking “Continue to Subscribe” button.

cloudformation marketplace 1

2. Please proceed by clicking “Accept Terms” button

cloudformation marketplace 2

3. if everything goes well, you will see the screenshot below.

cloudformation marketplace 3

4. Now, download the CloudFormation template from the below link to your computer.

Link: https://raw.githubusercontent.com/ant-media/Scripts/master/cloudformation/antmedia-aws-autoscale-template.yaml

5. Log in to the AWS Dashboard and find CloudFormation in the search box.

CloudFormation ant media server

6. Click on "Create Stack" from the menu.

CloudFormation Start Page

7. Select "Upload a Template File" and upload the downloaded file.

aws cloudformation screen

8. The menu that below is where we will adjust all our settings.

Ant media server cloud formation setup- Stack Name: it will describe your stacks, it will be like a skeleton
- AntMediaEdgeCapacity: How many Edge servers will be created.
- AntMediaEdgeCapacityMax: Edge Server where Auto Scale will reach maximum
- AntMediaOriginCapacity: How many Origin servers will be created.
- AntMediaOriginCapacityMax: Origin Server where Auto Scale will reach maximum
- CPUPolicyTargetValue: Average CPU utilization of the Auto Scaling group. When the server reaches %60 CPU utilization average, new servers will be added
- EdgeInstanceType: Edge Instance Type

AntMedia CloudFormation 4 1 2

- Email: Subscription Email
- KeyName: An Amazon EC2 key pair name.If there is no value here, you must create an ssh key (EC2 > Key Pairs).
- LoadBalancerCertificateArn: Amazon Resource Name (ARN) of the certificate to associate with the load balancer. Please check this guide: https://antmedia.io/ssl-from-aws-certificate-manager-for-domain-name/
- MongoDBInstanceType: MongoDB Instance Type
- OriginInstanceType: Origin Server Instance Type
- RTMP: If you want to install the RTMP Load balancer, please select True
- SSHLocation: The IP address range that can be used to SSH to the EC2 instances
- Subnets: The list of SubnetIDs in your Virtual Private Cloud (VPC). You must choose at least 2 subnets from the same VPC network.
- VpcCidrBlock: Associates a CIDR block with your VPC. It should be the same as the VPC Network.
- VpcId: VpcId of your existing Virtual Private Cloud (VPC). The VpcId must be the same as the subnets you choose.

9. Please proceed by clicking “Next” button

aws cloud formation

10. In this section, you can view and check the summary of the parameters you have entered and you can edit it here as below.AntMedia CloudFormation 6

We are using AWS Lambda, so IAM permissions are needed to get our latest image.

AWS Lambda

11. If the template has been installed successfully, it says "Create Complete" in the red rectangle.aws ant media cluster

12. You can access the URL addresses for LoadBalancer HTTP and HTTPS in the Outputs tab. If you define the CNAME record for the domain you have defined on Certificate Manager to the Load Balancer address below, you can access Ant Media Server without a certificate error on the domain you have defined.ant media cluster

13. When you type the URL of the Loadbalancer, Ant Media Dashboard will be opened as below.ant media login screen

When you click on the Cluster tab, you can see the servers in Cluster.

Ant media server in Cluster.

14. When you delete a stack, the AWS CloudFormation deletes all resources in that stack.
AWS CloudFormation deletes

I have covered most of the topics around Cloud Formation. Coming to the question of what we have gained by using CloudFormation and Ant Media Server template, the following steps will take place while sipping your coffee.

- EC2 instance
- Security group
- Ant Media Server Installation
- Ant Media Server Cluster Configuration
- AutoScale
- Load Balancer

If you have any questions, please just drop a line to contact (at) antmedia.io

Categories: Tutorial

Murat Ugur

Murat is a Software Developer and a Technical Support Engineer at the same time at Ant Media. With a remarkable 15+ years in the IT domain, including 13 years dedicated to Linux System administration, Murat brings a wealth of experience to the table. His expertise is grounded in technologies like bash scripting, python, and puppet.

chatsimple