Skip to content

Commit

Permalink
Merge branch 'master' into add_aws_wizard_service
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohit-3196 authored Nov 28, 2023
2 parents d51e7b6 + 25db333 commit bce77fd
Show file tree
Hide file tree
Showing 7 changed files with 405 additions and 516 deletions.
269 changes: 115 additions & 154 deletions cloudformation/antmedia-aws-autoscale-remote_db-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ Parameters:
AllowedPattern: >-
([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)
ConstraintDescription: must be a valid email address.
DashboardPassword:
Description: 'Web Panel Password'
Type: String
Default: ''
AntMediaOriginCapacity:
Default: '1'
Description: The initial number of Ant Media Origin instances
Expand Down Expand Up @@ -441,91 +437,93 @@ Resources:
- 'autoscaling:EC2_INSTANCE_LAUNCH_ERROR'
- 'autoscaling:EC2_INSTANCE_TERMINATE'
- 'autoscaling:EC2_INSTANCE_TERMINATE_ERROR'
LaunchConfigOrigin:
Type: 'AWS::AutoScaling::LaunchConfiguration'
DependsOn:
- ApplicationLoadBalancer
Metadata:
Comment: Install a simple application
'AWS::CloudFormation::Init':
configSets:
setup:
- "configure_cfn"
configure_cfn:
files:
/etc/cfn/cfn-hup.conf:
content: !Sub |
[main]
stack=${AWS::StackId}
region=${AWS::Region}
verbose=true
interval=5
mode: "000400"
owner: root
group: root
/etc/cfn/hooks.d/cfn-auto-reloader.conf:
content: !Sub |
[cfn-auto-reloader-hook]
triggers=post.update
path=Resources.LaunchConfigOrigin.Metadata.AWS::CloudFormation::Init
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfigOrigin --configsets setup --region ${AWS::Region}
mode: "000400"
owner: root
group: root
/lib/systemd/system/cfn-hup.service:
content: !Sub |
[Unit]
Description=cfn-hup daemon
[Service]
Type=simple
ExecStart=/opt/aws/bin/cfn-hup
Restart=always
[Install]
WantedBy=multi-user.target
mode: "000400"
owner: root
group: root
OriginGroup:
Type: 'AWS::AutoScaling::AutoScalingGroup'
DependsOn:
- LaunchTemplateOrigin
Properties:
VPCZoneIdentifier:
- !Ref OriginZone
LaunchTemplate:
LaunchTemplateName: !Sub ${AWS::StackName}-AntMedia-LaunchTemplateOrigin
Version: !GetAtt 'LaunchTemplateOrigin.LatestVersionNumber'
MinSize: !Ref AntMediaOriginCapacity
MaxSize: !Ref AntMediaOriginCapacityMax
DesiredCapacity: !Ref AntMediaOriginCapacity
TargetGroupARNs:
- !Ref ALBTargetGroupOrigin
- !Ref RTMPTargetGroup
Tags:
- Key: Name
Value: Antmedia-Origin
PropagateAtLaunch: 'true'
CreationPolicy:
ResourceSignal:
Timeout: PT15M
Count: !Ref AntMediaOriginCapacity
UpdatePolicy:
AutoScalingRollingUpdate:
MinInstancesInService: '1'
MaxBatchSize: '1'
PauseTime: PT15M
WaitOnResourceSignals: 'true'
NotificationConfiguration:
TopicARN: !Ref NotificationTopic
NotificationTypes:
- 'autoscaling:EC2_INSTANCE_LAUNCH'
- 'autoscaling:EC2_INSTANCE_LAUNCH_ERROR'
- 'autoscaling:EC2_INSTANCE_TERMINATE'
- 'autoscaling:EC2_INSTANCE_TERMINATE_ERROR'

LaunchTemplateOrigin:
Type: 'AWS::EC2::LaunchTemplate'
Properties:
KeyName: !Ref KeyName
ImageId: !Ref AntMediaAmi
SecurityGroups:
- !Ref InstanceSecurityGroup
InstanceType: !Ref OriginInstanceType
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: !Ref DiskSize
VolumeType: gp2
DeleteOnTermination: true
UserData:
Fn::Base64: !Sub |
#!/bin/bash
touch /usr/local/antmedia/conf/initialized
wget https://raw.githubusercontent.com/ant-media/Scripts/master/init.sh -O /usr/local/antmedia/conf/init.sh
sed -i 's/$INSTANCE_ID/${DashboardPassword}/g' /usr/local/antmedia/conf/init.sh
bash /usr/local/antmedia/change_server_mode.sh cluster ${MongoDBURL} ${MongoDBUsername} ${MongoDBPassword}
rm -rf /usr/local/antmedia/conf/initialized
bash /usr/local/antmedia/conf/init.sh cf
apt-get update -y
apt-get install -y python3-pip
apt-get install -y python3-setuptools
mkdir -p /opt/aws/bin
wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
python3 -m easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-py3-latest.tar.gz
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfigOrigin --configsets setup --region ${AWS::Region}
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource OriginGroup --region ${AWS::Region}
LaunchTemplateName: !Sub ${AWS::StackName}-AntMedia-LaunchTemplateOrigin
LaunchTemplateData:
InstanceType: !Ref OriginInstanceType
KeyName: !Ref KeyName
ImageId: !Ref AntMediaAmi
SecurityGroupIds:
- !GetAtt "InstanceSecurityGroup.GroupId"
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: !Ref DiskSize
VolumeType: gp2
DeleteOnTermination: true
UserData:
Fn::Base64: !Sub |
#!/bin/bash
touch /usr/local/antmedia/conf/initialized
bash /usr/local/antmedia/change_server_mode.sh cluster ${DBInstance.PrivateIp}
apt-get update
apt-get install -y python3-pip
apt-get install -y python3-setuptools
mkdir -p /opt/aws/bin
wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
python3 -m easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-py3-latest.tar.gz
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource OriginGroup --region ${AWS::Region}
TagSpecifications:
- ResourceType: instance
Tags:
- Key: Name
Value: OriginInstance
TagSpecifications:
- ResourceType: launch-template
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-AntMedia-LaunchTemplateOrigin

EdgeGroup:
Type: 'AWS::AutoScaling::AutoScalingGroup'
DependsOn:
- LaunchConfigEdge
- LaunchTemplateEdge
Properties:
VPCZoneIdentifier:
- !Ref EdgeZone
LaunchConfigurationName: !Ref LaunchConfigEdge
LaunchTemplate:
LaunchTemplateName: !Sub ${AWS::StackName}-AntMedia-LaunchTemplateEdge
Version: !GetAtt 'LaunchTemplateEdge.LatestVersionNumber'
MinSize: !Ref AntMediaEdgeCapacity
MaxSize: !Ref AntMediaEdgeCapacityMax
DesiredCapacity: !Ref AntMediaEdgeCapacity
Expand All @@ -552,78 +550,45 @@ Resources:
- 'autoscaling:EC2_INSTANCE_LAUNCH_ERROR'
- 'autoscaling:EC2_INSTANCE_TERMINATE'
- 'autoscaling:EC2_INSTANCE_TERMINATE_ERROR'
LaunchConfigEdge:
Type: 'AWS::AutoScaling::LaunchConfiguration'
DependsOn:
- ApplicationLoadBalancer
Metadata:
Comment: Install a simple application
'AWS::CloudFormation::Init':
configSets:
setup:
- "configure_cfn"
configure_cfn:
files:
/etc/cfn/cfn-hup.conf:
content: !Sub |
[main]
stack=${AWS::StackId}
region=${AWS::Region}
verbose=true
interval=5
mode: "000400"
owner: root
group: root
/etc/cfn/hooks.d/cfn-auto-reloader.conf:
content: !Sub |
[cfn-auto-reloader-hook]
triggers=post.update
path=Resources.LaunchConfigEdge.Metadata.AWS::CloudFormation::Init
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfigEdge --configsets setup --region ${AWS::Region}
mode: "000400"
owner: root
group: root
/lib/systemd/system/cfn-hup.service:
content: !Sub |
[Unit]
Description=cfn-hup daemon
[Service]
Type=simple
ExecStart=/opt/aws/bin/cfn-hup
Restart=always
[Install]
WantedBy=multi-user.target
mode: "000400"
owner: root
group: root

LaunchTemplateEdge:
Type: 'AWS::EC2::LaunchTemplate'
Properties:
KeyName: !Ref KeyName
ImageId: !Ref AntMediaAmi
SecurityGroups:
- !Ref InstanceSecurityGroup
InstanceType: !Ref EdgeInstanceType
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: !Ref DiskSize
VolumeType: gp2
DeleteOnTermination: true
UserData:
Fn::Base64: !Sub |
#!/bin/bash
touch /usr/local/antmedia/conf/initialized
bash /usr/local/antmedia/change_server_mode.sh cluster ${MongoDBURL} ${MongoDBUsername} ${MongoDBPassword}
apt-get update
apt-get install -y python3-pip
apt-get install -y python3-setuptools
mkdir -p /opt/aws/bin
wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
python3 -m easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-py3-latest.tar.gz
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfigEdge --configsets setup --region ${AWS::Region}
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource EdgeGroup --region ${AWS::Region}
LaunchTemplateName: !Sub ${AWS::StackName}-AntMedia-LaunchTemplateEdge
LaunchTemplateData:
InstanceType: !Ref EdgeInstanceType
KeyName: !Ref KeyName
ImageId: !Ref AntMediaAmi
SecurityGroupIds:
- !GetAtt "InstanceSecurityGroup.GroupId"
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: !Ref DiskSize
VolumeType: gp2
DeleteOnTermination: true
UserData:
Fn::Base64: !Sub |
#!/bin/bash
touch /usr/local/antmedia/conf/initialized
bash /usr/local/antmedia/change_server_mode.sh cluster ${DBInstance.PrivateIp}
apt-get update
apt-get install -y python3-pip
apt-get install -y python3-setuptools
mkdir -p /opt/aws/bin
wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
python3 -m easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-py3-latest.tar.gz
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource EdgeGroup --region ${AWS::Region}
TagSpecifications:
- ResourceType: instance
Tags:
- Key: Name
Value: EdgeInstance
TagSpecifications:
- ResourceType: launch-template
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-AntMedia-LaunchTemplateEdge

ELBSecurityGroup:
Type: AWS::EC2::SecurityGroup
Expand Down Expand Up @@ -815,10 +780,6 @@ Resources:

Outputs:

Password:
Description: Dashboard Password
Value: !Ref DashboardPassword

OriginHTTPS:
Description: HTTPS URL of the Ant Media Origin Servers
Value: !Join
Expand Down
Loading

0 comments on commit bce77fd

Please sign in to comment.