This repository was archived by the owner on Sep 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathbbb-on-aws-application.template.yaml
More file actions
283 lines (261 loc) · 10.1 KB
/
bbb-on-aws-application.template.yaml
File metadata and controls
283 lines (261 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
---
AWSTemplateFormatVersion: '2010-09-09'
Description: >
This Cloudformation Template deploys the scalable option of the BigBlueButton application server.
Disclaimer: Not for production use. Demo and testing purposes only.
Author: David Surey <suredavi@amazon.com>
Parameters:
BBBApplicationVersion:
Description: Application Version for BBB
Type: String
Default: focal-270
BBBOperatorEMail:
Description: E-Mail address to notify if there are any operational issues
Type: String
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.
Default: johndoe@example.com
BBBNotificationTopic:
Description: Topic to be used for alarm notifications
Type: String
BBBApplicationSubnets:
Description: Comma separated list of the appserver's subnets
Type: CommaDelimitedList
BBBECSTaskSecurityGroup:
Description: Security Group that should be assigned for the Task Instances
Type: String
BBBApplicationInstanceAMI:
Description: Ubuntu AMI ID for Application Instances
Type: String
BBBApplicationInstanceType:
Description: Instance type for BBB Application Server (x86_64 only)
Type: String
Default: c5.2xlarge
AllowedPattern: ^(t3|t3a|m5|m5a|m5n|m5zn|m6i|m6a|m6in|c5|c5a|c5n|c6i|c6a|c6in|r5|r5a|r5b|r5n|r6i|r6a|r6in)\.(medium|large|xlarge|2xlarge|4xlarge|8xlarge|12xlarge|16xlarge|24xlarge)$
BBBApplicationDataVolumeSize:
Description: Size of the application instance data volume
Type: Number
Default: 20
BBBApplicationRootVolumeSize:
Description: Size of the application instance data volume
Type: Number
Default: 20
BBBApplicationMaxInstances:
Type: Number
Description: Maximum number of appserver instances
Default: 3
BBBApplicationMinInstances:
Type: Number
Description: Minimum number of appserver instances
Default: 1
BBBApplicationDesiredInstances:
Type: Number
Description: Desired number of appserver instances
Default: 1
BBBSharedStorageFS:
Description: File system id for the Amazon EFS volume to be mounted
Type: String
BBBSharedStorageAPspool:
Description: Access Point id for the Amazon EFS volume to be mounted
Type: String
BBBApplicationSecurityGroup:
Description: Security Group that should be assigned for the appserver
Type: String
BBBHostedZone:
Description: Hosted zone in which the DNS entries for the app servers should be created
Type: String
BBBDomainName:
Description: Base domain name used for the instance
Type: String
BBBStackBucketStack:
Description: S3 Bucket Stack that contains scripts and sources
Type: String
BBBECSCluster:
Description: ECS Cluster reference
Type: String
BBBScaleliteTaskExecutionRole:
Description: Task execution role used by the Scalelite ECS task
Type: String
BBBSystemLogsGroup:
Description: Log group to be used for the system logs
Type: String
BBBApplicationLogsGroup:
Description: Log group to be used for the Application logs
Type: String
BBBSystemLogsGroupArn:
Description: Log group to be used for the system logs
Type: String
BBBApplicationLogsGroupArn:
Description: Log group to be used for the Application logs
Type: String
BBBECSInstanceType:
Description: EC2 instance type for ECS Cluster worker nodes
Type: String
Resources:
BBBApplicationAutoScaling:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier: !Ref BBBApplicationSubnets
LaunchTemplate:
LaunchTemplateId: !Ref BBBApplicationInstanceLaunchTemplate
Version: !GetAtt BBBApplicationInstanceLaunchTemplate.LatestVersionNumber
TerminationPolicies:
- DEFAULT
MaxSize: !Ref BBBApplicationMaxInstances
MinSize: !Ref BBBApplicationMinInstances
DesiredCapacity: !Ref BBBApplicationDesiredInstances
NotificationConfiguration:
TopicARN:
Ref: BBBNotificationTopic
NotificationTypes:
- autoscaling:EC2_INSTANCE_LAUNCH
- autoscaling:EC2_INSTANCE_LAUNCH_ERROR
- autoscaling:EC2_INSTANCE_TERMINATE
- autoscaling:EC2_INSTANCE_TERMINATE_ERROR
CreationPolicy:
ResourceSignal:
Timeout: PT30M
UpdatePolicy:
AutoScalingReplacingUpdate:
WillReplace: true
BBBApplicationEC2Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [ ec2.amazonaws.com ]
Action: [ "sts:AssumeRole" ]
Path: /
Policies:
- PolicyName: bbbawsorchestrationaccess
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- route53:ChangeResourceRecordSets
- route53:GetHostedZone
- route53:ListResourceRecordSets
Resource: !Sub "arn:aws:route53:::hostedzone/${BBBHostedZone}"
- Effect: Allow
Action:
- s3:GetObject
Resource:
- !Sub "arn:aws:s3:::${BBBStackBucketStack}/*"
- Effect: Allow
Action:
- ecs:ListTaskDefinitions
- ecs:ListClusters
- ecs:ListTasks
Resource:
- "*"
- Effect: Allow
Action:
- ecs:RunTask
- ecs:ExecuteCommand
- ecs:DescribeTasks
- ecs:ListServices
Condition:
ArnEquals:
ecs:cluster: !Sub "arn:aws:ecs:${AWS::Region}:${AWS::AccountId}:cluster/${BBBECSCluster}"
Resource:
- "*"
- Effect: Allow
Action:
- iam:PassRole
Resource:
- !Ref BBBScaleliteTaskExecutionRole
- Effect: Allow
Action:
- logs:PutLogEvents
- logs:CreateLogStream
- logs:DescribeLogStreams
- logs:CreateLogGroup
Resource:
- !Ref BBBSystemLogsGroupArn
- !Ref BBBApplicationLogsGroupArn
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
BBBApplicationEC2InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path: /
Roles:
- !Ref BBBApplicationEC2Role
BBBApplicationInstanceLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateData:
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeType: gp2
VolumeSize: !Ref BBBApplicationRootVolumeSize
Encrypted: true
- DeviceName: /dev/sdf
Ebs:
VolumeSize: !Ref BBBApplicationDataVolumeSize
VolumeType: gp2
Encrypted: true
IamInstanceProfile:
Arn: !GetAtt BBBApplicationEC2InstanceProfile.Arn
ImageId: !Ref BBBApplicationInstanceAMI
InstanceType: !Ref BBBApplicationInstanceType
NetworkInterfaces:
- AssociatePublicIpAddress: true
DeviceIndex: 0
Groups:
- !Ref BBBApplicationSecurityGroup
UserData:
Fn::Base64: !Sub
- |
#!/bin/bash -xe
apt update -y
while fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock >/dev/null 2>&1; do sleep 1; done
DEBIAN_FRONTEND='noninteractive' apt -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade
apt autoremove -y
apt autoclean
while fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/lock >/dev/null 2>&1; do sleep 1; done
apt install -y dnsutils net-tools git jq unzip python3-pip binutils rustc cargo pkg-config libssl-dev gettext
cd /tmp
pip3 install -U https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
snap install aws-cli --classic
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb"
dpkg -i session-manager-plugin.deb
while fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do sleep 1; done
aws s3 cp s3://${BBBStackBucketStack}/bbb-bootstrap.sh /tmp/bbb-bootstrap.sh
chmod +x /tmp/bbb-bootstrap.sh
/tmp/bbb-bootstrap.sh -a ${BBBStackBucketStack} \
-b ${BBBSystemLogsGroup} \
-c ${BBBDomainName} \
-e ${BBBHostedZone} \
-g ${BBBOperatorEMail} \
-h ${BBBApplicationVersion} \
-i ${AWS::Region} \
-j ${BBBSharedStorageFS} \
-k ${BBBSharedStorageAPspool} \
-l ${BBBECSCluster} \
-m ${BBBECSInstanceType} \
-n "${BBBApplicationSubnetsString}" \
-o ${BBBECSTaskSecurityGroup}
/usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource BBBApplicationAutoScaling --region ${AWS::Region} || true
- BBBApplicationSubnetsString: !Join [",", !Ref BBBApplicationSubnets]
Outputs:
BBBApplicationEC2InstanceProfile:
Description: Big Blue Button Application Instance Profile
Value:
Ref: BBBApplicationEC2InstanceProfile
BBBApplicationEC2Role:
Description: Big Blue Button Application Instance Role
Value:
Ref: BBBApplicationEC2Role
BBBApplicationAutoScaling:
Description: Big Blue Button Application Instance Autoscaling Group
Value:
Ref: BBBApplicationAutoScaling
BBBApplicationInstanceLaunchTemplate:
Description: Big Blue Button Application Instance Launch Template
Value:
Ref: BBBApplicationInstanceLaunchTemplate