Skip to content

Commit

Permalink
Add Redis Serverless Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
muratugureminoglu committed Mar 19, 2024
1 parent ce9553f commit 5765672
Showing 1 changed file with 56 additions and 21 deletions.
77 changes: 56 additions & 21 deletions aws-custom-cluster/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,26 +211,6 @@ Resources:
RouteTableId: !Ref RouteTable
SubnetId: !Ref EdgeZone

OriginGroup:
Type: 'AWS::AutoScaling::AutoScalingGroup'
DependsOn:
- LaunchTemplateOrigin
Properties:
VPCZoneIdentifier:
- !Ref OriginZone
LaunchTemplate:
LaunchTemplateName: !Sub ${AWS::StackName}-AntMedia-LaunchTemplateOrigin
Version: !GetAtt 'LaunchTemplateOrigin.LatestVersionNumber'
MinSize: 0
MaxSize: 1
DesiredCapacity: 0
TargetGroupARNs:
- !Ref ALBTargetGroupOrigin
Tags:
- Key: Name
Value: Ant-Media-Server
PropagateAtLaunch: 'true'

ELBSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
Expand Down Expand Up @@ -324,6 +304,44 @@ Resources:
ListenerArn: !Ref ALBListener443
Priority: 1

RedisServerlessCache:
Type: AWS::ElastiCache::ServerlessCache
DependsOn:
- OriginGroup
Properties:
DailySnapshotTime: "03:00"
Description: "Ant Media Server - Redis Serverless Cache"
Engine: "Redis"
SecurityGroupIds:
- !GetAtt "InstanceSecurityGroup.GroupId"
ServerlessCacheName: !Sub ${AWS::StackName}-ServerlessRedis
SubnetIds:
- !Ref OriginZone
- !Ref EdgeZone
Tags:
- Key: Name
Value: RedisCache

OriginGroup:
Type: 'AWS::AutoScaling::AutoScalingGroup'
DependsOn:
- LaunchTemplateOrigin
Properties:
VPCZoneIdentifier:
- !Ref OriginZone
LaunchTemplate:
LaunchTemplateName: !Sub ${AWS::StackName}-AntMedia-LaunchTemplateOrigin
Version: !GetAtt 'LaunchTemplateOrigin.LatestVersionNumber'
MinSize: 0
MaxSize: 1
DesiredCapacity: 0
TargetGroupARNs:
- !Ref ALBTargetGroupOrigin
Tags:
- Key: Name
Value: Ant-Media-Server
PropagateAtLaunch: 'true'

LaunchTemplateOrigin:
Type: 'AWS::EC2::LaunchTemplate'
Properties:
Expand All @@ -343,7 +361,24 @@ Resources:
UserData:
Fn::Base64: !Sub |
#!/bin/bash
apt-get update
sudo apt-get update -y
sudo apt-get install stunnel -y
sudo tee /etc/stunnel/stunnel.conf > /dev/null <<EOF
fips = no
setuid = root
setgid = root
pid = /var/run/stunnel.pid
debug = 7
options = NO_SSLv2
options = NO_SSLv3
[redis-cli]
client = yes
accept = 127.0.0.1:6379
connect = ${RedisServerlessCache.Endpoint.Address}:6379
EOF
sudo systemctl enable stunnel4
sudo stunnel /etc/stunnel/stunnel.conf
bash /usr/local/antmedia/change_server_mode.sh standalone redis://localhost:6379
apt-get install -y python3-pip
apt-get install -y python3-setuptools
mkdir -p /opt/aws/bin
Expand Down

0 comments on commit 5765672

Please sign in to comment.