This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
jambonz-scalable-production.yaml
1981 lines (1873 loc) · 70.4 KB
/
jambonz-scalable-production.yaml
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
AWSTemplateFormatVersion: "2010-09-09"
Mappings:
AWSRegion2AMI:
us-east-1:
SbcSipAmi: ami-01bd8823d7269c0c8
SbcRtpAmi: ami-0954b7e5aaf4ee966
FsAmi: ami-0afdc9cef2c7e3e24
WebserverAmi: ami-0b0b877726e51a31c
MonitoringServerAmi: ami-0aaa644b8462b7a6b
eu-central-1:
SbcSipAmi: ami-0eb4a42513512f83c
SbcRtpAmi: ami-0193b4d53092ab162
FsAmi: ami-096cfff649d965aef
WebserverAmi: ami-0ad690b17d163c794
MonitoringServerAmi: ami-010baeedfe1041c1b
Parameters:
KeyName:
Description: "The keypair that you will use to access the EC2 instances via ssh"
Type: "AWS::EC2::KeyPair::KeyName"
InstanceTypeSbcSip:
Description: "the EC2 instance type for the SBC SIP server"
Type: String
Default: t2.small
AllowedValues:
- t2.small
- t2.medium
- t2.large
- t2.xlarge
- t3.small
- t3.medium
- t3.large
- t3.xlarge
- t3a.small
- t3a.medium
- t3a.large
- t3a.xlarge
- c5.large
- c5.xlarge
- c5.2xlarge
- c5n.large
- c5n.xlarge
- c5n.2xlarge
- c5n.4xlarge
- c5n.18xlarge
- c5n.metal
InstanceTypeSbcRtp:
Description: "the EC2 instance type to use for the SBC Media server"
Type: String
Default: t2.small
AllowedValues:
- t2.small
- t2.medium
- t2.large
- t2.xlarge
- t3.small
- t3.medium
- t3.large
- t3.xlarge
- t3a.small
- t3a.medium
- t3a.large
- t3a.xlarge
- c5.large
- c5.xlarge
- c5.2xlarge
- c5n.large
- c5n.xlarge
- c5n.2xlarge
- c5n.4xlarge
- c5n.18xlarge
- c5n.metal
InstanceTypeFeatureServer:
Description: "the EC2 instance type to use for the Feature Server"
Type: String
Default: t2.small
AllowedValues:
- t2.small
- t2.medium
- t2.large
- t2.xlarge
- t3.small
- t3.medium
- t3.large
- t3.xlarge
- t3a.small
- t3a.medium
- t3a.large
- t3a.xlarge
- c5.large
- c5.xlarge
- c5.2xlarge
- c5n.large
- c5n.xlarge
- c5n.2xlarge
- c5n.4xlarge
- c5n.18xlarge
- c5n.metal
InstanceTypeWebserver:
Description: "the EC2 instance type to use for webServer"
Type: String
Default: t2.small
AllowedValues:
- t2.small
- t2.medium
- t2.large
- t2.xlarge
- t3.small
- t3.medium
- t3.large
- t3.xlarge
- t3a.small
- t3a.medium
- t3a.large
- t3a.xlarge
- c5.large
- c5.xlarge
- c5.2xlarge
- c5n.large
- c5n.xlarge
- c5n.2xlarge
- c5n.4xlarge
- c5n.18xlarge
- c5n.metal
InstanceTypeMonitoringServer:
Description: "the EC2 instance type for the monitoring server"
Type: String
Default: t2.small
AllowedValues:
- t2.small
- t2.medium
- t2.large
- t2.xlarge
- t3.small
- t3.medium
- t3.large
- t3.xlarge
- t3a.small
- t3a.medium
- t3a.large
- t3a.xlarge
- c5.large
- c5.xlarge
- c5.2xlarge
- c5n.large
- c5n.xlarge
- c5n.2xlarge
- c5n.4xlarge
- c5n.18xlarge
- c5n.metal
ElastiCacheNodeType:
Type: String
Default: 'cache.t2.medium'
AllowedValues:
- cache.t3.micro
- cache.t3.small
- cache.t3.medium
- cache.t2.small
- cache.t2.medium
- cache.m6g.large
- cache.m6g.xlarge
- cache.m6g.2xlarge
- cache.m6g.4xlarge
- cache.m6g.8xlarge
- cache.m6g.12xlarge
- cache.m6g.16xlarge
- cache.m5.large
- cache.m5.xlarge
- cache.m5.2xlarge
- cache.m5.4xlarge
- cache.m5.12xlarge
- cache.m5.24xlarge
- cache.r6g.large
- cache.r6g.xlarge
- cache.r6g.2xlarge
- cache.r6g.4xlarge
- cache.r6g.8xlarge
- cache.r6g.12xlarge
- cache.r6g.16xlarge
- cache.r5.large
- cache.r5.xlarge
- cache.r5.2xlarge
- cache.r5.4xlarge
- cache.r5.12xlarge
- cache.r5.24xlarge
AuroraDBMinCapacity:
Description: "min capacity for database"
Type: Number
Default: 1
AuroraDBMaxCapacity:
Description: "max capacity for database"
Type: Number
Default: 4
AllowedValues:
- 1
- 2
- 4
- 8
- 16
- 32
- 64
- 128
- 256
Prefix:
Description: "Name of VPC and other identifiers - lower case letters only"
Type: "String"
Default: "jb"
AllowedSshCidr:
Description: Please set CIDR to x.x.x.x/32 to allow one specific IP address ssh access, 0.0.0.0/0 to allow all IP addresses access, or another CIDR range.
Type: String
AllowedPattern: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}
ConstraintDescription: must be a valid network CIDR
AllowedHttpCidr:
Description: Please set CIDR to x.x.x.x/32 to allow one specific IP address http(s) access, 0.0.0.0/0 to allow all IP addresses access, or another CIDR range.
Type: String
AllowedPattern: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}
ConstraintDescription: must be a valid network CIDR
Default: 0.0.0.0/0
AllowedSipCidr:
Description: Please set CIDR to x.x.x.x/32 to allow one specific IP address sip access, 0.0.0.0/0 to allow all IP addresses access, or another CIDR range.
Type: String
ConstraintDescription: must be a valid network CIDR
AllowedPattern: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}
Default: 0.0.0.0/0
AllowedSmppCidr:
Description: Please set CIDR to x.x.x.x/32 to allow one specific IP address smpp access, 0.0.0.0/0 to allow all IP addresses access, or another CIDR range.
Type: String
ConstraintDescription: must be a valid network CIDR
AllowedPattern: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}
Default: 0.0.0.0/0
AllowedRtpCidr:
Description: Please set CIDR to x.x.x.x/32 to allow one specific IP address to send RTP traffic, 0.0.0.0/0 to allow all IP addresses access, or another CIDR range.
Type: String
ConstraintDescription: must be a valid network CIDR
AllowedPattern: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}
Default: 0.0.0.0/0
VpcCIDR:
Description: "The CIDR block for the whole VPC"
Type: "String"
Default: '172.20.0.0/16'
PublicSubnet1CIDR:
Description: "Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone"
Type: "String"
Default: '172.20.10.0/24'
PublicSubnet2CIDR:
Description: "Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone"
Type: "String"
Default: '172.20.11.0/24'
MySQLUsername:
Description: 'the database username'
Type: String
Default: 'admin'
MySQLPassword:
NoEcho: true
Description: 'The database admin account password'
Type: String
Default: 'JambonzR0ck$'
EncryptionSecret:
Type: String
Description: "secret to use for encrypting jwt and other data"
Default: "G=u$Dj%-97#TffYf"
URLPortal:
Type: String
Description: "DNS name you will point to the jambonz webserver(s)"
Default: "yourdomain.com"
StatsSampleRate:
Type: Number
Description: sampling rate for metrics, a number between 0 and 1 inclusive
Default: 1
DbCachingTTS:
Type: Number
Description: Number of seconds to cache results from DB queries (0=no caching)
Default: 0
Cloudwatch:
Description: Send jambonz logs to cloudwatch
Type: String
Default: true
AllowedValues: [true, false]
CloudwatchLogRetention:
Description: "Number of days to retain cloudwatch logs"
Type: Number
Default: 3
AllowedValues:
- 1
- 3
- 5
- 7
- 14
- 30
- 60
- 90
- 120
- 150
Resources:
###########################################
#
# VPC Resources
#
###########################################
VPC:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: !Ref "VpcCIDR"
Tags:
- Key: "Name"
Value: !Sub "${Prefix}-VPC"
# Create Internet Gateway
InternetGateway:
Type: "AWS::EC2::InternetGateway"
Properties:
Tags:
- Key: "Name"
Value: !Sub "${Prefix}-IGW"
# Attach Internet Gateway to VPC
GatewayToInternet:
Type: "AWS::EC2::VPCGatewayAttachment"
Properties:
VpcId: !Ref "VPC"
InternetGatewayId: !Ref "InternetGateway"
# Create Public Subnet
PublicSubnet1:
Type: "AWS::EC2::Subnet"
Properties:
VpcId: !Ref "VPC"
CidrBlock: !Ref "PublicSubnet1CIDR"
AvailabilityZone: !Select [ '0', !GetAZs ]
MapPublicIpOnLaunch: "True"
Tags:
- Key: "Name"
Value: !Sub "${Prefix}-${PublicSubnet1CIDR}-PublicSubnet1"
PublicSubnet2:
Type: "AWS::EC2::Subnet"
Properties:
VpcId: !Ref "VPC"
CidrBlock: !Ref "PublicSubnet2CIDR"
AvailabilityZone: !Select [ '1', !GetAZs ]
MapPublicIpOnLaunch: "True"
Tags:
- Key: "Name"
Value: !Sub "${Prefix}-${PublicSubnet2CIDR}-PublicSubnet2"
# Create Public Route Table 1
PublicRouteTable1:
Type: "AWS::EC2::RouteTable"
Properties:
VpcId: !Ref "VPC"
Tags:
- Key: "Name"
Value: !Sub "${Prefix}-PublicRoute1"
# Create Public Route Table 2
PublicRouteTable2:
Type: "AWS::EC2::RouteTable"
Properties:
VpcId: !Ref "VPC"
Tags:
- Key: "Name"
Value: !Sub "${Prefix}-PublicRoute2"
# Route-out Public Route Table to Internet Gateway (Internet connection)
PublicRouteIGW1:
Type: "AWS::EC2::Route"
DependsOn: "GatewayToInternet"
Properties:
RouteTableId: !Ref "PublicRouteTable1"
DestinationCidrBlock: "0.0.0.0/0"
GatewayId: !Ref "InternetGateway"
PublicRouteIGW2:
Type: "AWS::EC2::Route"
DependsOn: "GatewayToInternet"
Properties:
RouteTableId: !Ref "PublicRouteTable2"
DestinationCidrBlock: "0.0.0.0/0"
GatewayId: !Ref "InternetGateway"
# Associate Public Route Table with Public Subnet1 & Subnet2
PublicSubnet1RouteTableAssociation:
Type: "AWS::EC2::SubnetRouteTableAssociation"
Properties:
SubnetId: !Ref "PublicSubnet1"
RouteTableId: !Ref "PublicRouteTable1"
PublicSubnet2RouteTableAssociation:
Type: "AWS::EC2::SubnetRouteTableAssociation"
Properties:
SubnetId: !Ref "PublicSubnet2"
RouteTableId: !Ref "PublicRouteTable2"
###########################################
#
# SECURITY GROUPS
#
###########################################
SshSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Sub '${Prefix}-jambonz-ssh-sg'
GroupDescription: !Sub 'Security group for ssh to ${Prefix} jambonz cluster'
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: !Ref AllowedSshCidr
Description: Allow SSH access
RedisSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Sub '${Prefix}-redis-sg'
GroupDescription: !Sub 'Security group for ${Prefix} Redis'
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 6379
ToPort: 6379
CidrIp: !Ref VpcCIDR
Description: Allow traffic from VPC
SecurityGroupEgress:
- IpProtocol: -1
FromPort: 0
ToPort: 0
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub '${Prefix}-redis-sg'
MySQLSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Sub '${Prefix}-mysql-sg'
GroupDescription: !Sub 'Security group for ${Prefix} MySQL'
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3306
ToPort: 3306
CidrIp: !Ref VpcCIDR
Description: Allow HTTP traffic from VPC
SecurityGroupEgress:
- IpProtocol: -1
FromPort: 0
ToPort: 0
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub '${Prefix}-mysql-sg'
FeatureServerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Sub '${Prefix}-feature-server-sg'
GroupDescription: !Sub 'Security group for ${Prefix} Feature Server'
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3000
ToPort: 3009
CidrIp: !Ref VpcCIDR
Description: Allow HTTP from sbc/api server
- IpProtocol: tcp
FromPort: 3010
ToPort: 3019
CidrIp: !Ref AllowedHttpCidr
Description: Allow http access from AWS SNS
- IpProtocol: tcp
FromPort: 5060
ToPort: 5060
CidrIp: !Ref VpcCIDR
Description: Allow sip from VPC
- IpProtocol: udp
FromPort: 5060
ToPort: 5060
CidrIp: !Ref VpcCIDR
Description: Allow sip from VPC
- IpProtocol: udp
FromPort: 25000
ToPort: 40000
CidrIp: !Ref VpcCIDR
Description: rtp
SecurityGroupEgress:
- IpProtocol: -1
FromPort: 0
ToPort: 0
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub '${Prefix}-feature-server-sg'
WebserverSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Sub '${Prefix}-webserver-sg'
GroupDescription: !Sub 'Security group for ${Prefix} WebServer'
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: !Ref AllowedHttpCidr
Description: Allow HTTP access
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: !Ref AllowedHttpCidr
Description: Allow HTTPS access
- IpProtocol: tcp
FromPort: 3000
ToPort: 3000
SourceSecurityGroupId: !Ref FeatureServerSecurityGroup
Description: Allow HTTPS access
SecurityGroupEgress:
- IpProtocol: -1
FromPort: 0
ToPort: 0
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub '${Prefix}-webserver-sg'
SbcSipSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Sub '${Prefix}-sbc-sip-sg'
GroupDescription: !Sub 'Security group for ${Prefix} Sbc Sip Server'
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3000
ToPort: 3009
CidrIp: !Ref VpcCIDR
Description: Allow HTTP from sbc/api server
- IpProtocol: tcp
FromPort: 3010
ToPort: 3019
CidrIp: !Ref AllowedHttpCidr
Description: Allow http access from AWS SNS
- IpProtocol: tcp
FromPort: 5060
ToPort: 5060
CidrIp: !Ref AllowedSipCidr
Description: Allow sip (tcp) from Internet
- IpProtocol: udp
FromPort: 5060
ToPort: 5060
CidrIp: !Ref AllowedSipCidr
Description: Allow sip (udp) from Internet
- IpProtocol: tcp
Description: sip over wss
FromPort: 8443
ToPort: 8443
CidrIp: !Ref AllowedSipCidr
- IpProtocol: tcp
FromPort: 5061
ToPort: 5061
CidrIp: '52.114.148.0/32'
Description: sip (tls) for teams
- IpProtocol: tcp
FromPort: 5061
ToPort: 5061
CidrIp: '52.114.132.46/32'
Description: sip (tls) for teams
- IpProtocol: tcp
FromPort: 5061
ToPort: 5061
CidrIp: '52.114.75.24/32'
Description: sip (tls) for teams
- IpProtocol: tcp
FromPort: 5061
ToPort: 5061
CidrIp: '52.114.76.76/32'
Description: sip (tls) for teams
- IpProtocol: tcp
FromPort: 5061
ToPort: 5061
CidrIp: '52.114.7.24/32'
Description: sip (tls) for teams
- IpProtocol: tcp
FromPort: 5061
ToPort: 5061
CidrIp: '52.114.14.70/32'
Description: sip (tls) for teams
- IpProtocol: tcp
FromPort: 4433
ToPort: 4433
CidrIp: !Ref AllowedSipCidr
Description: Allow sip (wss) from Internet
- IpProtocol: tcp
FromPort: 2775
ToPort: 2775
CidrIp: !Ref AllowedSmppCidr
Description: Allow SMPP/tcp from Internet
- IpProtocol: tcp
FromPort: 3550
ToPort: 3550
CidrIp: !Ref AllowedSmppCidr
Description: Allow SMPP/tls from Internet
- IpProtocol: tcp
FromPort: 3020
ToPort: 3020
SourceSecurityGroupId: !Ref FeatureServerSecurityGroup
Description: Allow HTTP access from VPC to jambonz-smpp-esme
- IpProtocol: tcp
FromPort: 9090
ToPort: 9090
CidrIp: !Ref VpcCIDR
Description: Allow access to prometheus scrape port from VPC
- IpProtocol: udp
FromPort: 22224
ToPort: 22233
CidrIp: !Ref VpcCIDR
Description: Allow dtmf events from rtpengine-sidecar in the VPC
SecurityGroupEgress:
- IpProtocol: -1
FromPort: 0
ToPort: 0
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub '${Prefix}-sbc-sip-sg'
SbcRTPSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Sub '${Prefix}-spc-rtp-sg'
GroupDescription: !Sub 'Security group for ${Prefix} sbc RTP'
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: udp
FromPort: 40000
ToPort: 60000
CidrIp: !Ref AllowedRtpCidr
Description: Allow RTP from everywhere
- IpProtocol: udp
FromPort: 5060
ToPort: 5060
CidrIp: !Ref VpcCIDR
Description: Allow Freeswitch sip from VPC
- IpProtocol: udp
FromPort: 22222
ToPort: 22223
CidrIp: !Ref VpcCIDR
Description: Allow rtpengine ng protocol from VPC
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: !Ref VpcCIDR
Description: rtpengine ws protocol from VPC
- IpProtocol: tcp
FromPort: 3001
ToPort: 3001
CidrIp: !Ref AllowedHttpCidr
Description: Allow http access from AWS SNS
SecurityGroupEgress:
- IpProtocol: -1
FromPort: 0
ToPort: 0
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub '${Prefix}-spc-rtp-sg'
MonitoringSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: !Sub '${Prefix}-monitoring-sg'
GroupDescription: !Sub 'Security group for ${Prefix} Monitoring'
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3000
ToPort: 3000
CidrIp: !Ref AllowedHttpCidr
Description: Allow grafana access
- IpProtocol: tcp
FromPort: 8086
ToPort: 8086
CidrIp: !Ref VpcCIDR
Description: Allow influxdb access from VPC
- IpProtocol: tcp
FromPort: 8088
ToPort: 8088
CidrIp: !Ref VpcCIDR
Description: Allow influxdb backup access from VPC
- IpProtocol: tcp
FromPort: 9080
ToPort: 9080
CidrIp: !Ref VpcCIDR
Description: Allow access to homer webapp
- IpProtocol: udp
FromPort: 9060
ToPort: 9060
CidrIp: !Ref VpcCIDR
Description: Allow access to homer HEP
- IpProtocol: tcp
FromPort: 16686
ToPort: 16686
CidrIp: !Ref VpcCIDR
Description: jaeger-query
- IpProtocol: tcp
FromPort: 14268
ToPort: 14269
CidrIp: !Ref VpcCIDR
Description: jaeger-collector (jaeger-thrift, health check)
SecurityGroupEgress:
- IpProtocol: -1
FromPort: 0
ToPort: 0
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub '${Prefix}-monitoring-sg'
###########################################
#
# Aurora RDS Database
#
###########################################
DatabaseSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupName: !Sub '${Prefix}-aurora-mysql-subnetgroup'
DBSubnetGroupDescription: CloudFormation managed DB subnet group.
SubnetIds:
- !Ref PublicSubnet1
- !Ref PublicSubnet2
DatabaseCluster:
Type: AWS::RDS::DBCluster
Properties:
DBClusterIdentifier: !Sub '${Prefix}-aurora-mysql-cluster'
Engine: aurora-mysql
EngineMode: serverless
EngineVersion: '5.7'
MasterUsername: !Ref MySQLUsername
MasterUserPassword: !Ref MySQLPassword
DatabaseName: 'jambones'
BackupRetentionPeriod: 5
PreferredBackupWindow: "07:00-09:00"
DBSubnetGroupName: !Ref DatabaseSubnetGroup
VpcSecurityGroupIds:
- !Ref MySQLSecurityGroup
ScalingConfiguration:
AutoPause: false
MaxCapacity: !Ref AuroraDBMaxCapacity
MinCapacity: !Ref AuroraDBMinCapacity
###########################################
#
# ElastiCache Redis
#
###########################################
ElastiCacheSubnetGroup:
Type: 'AWS::ElastiCache::SubnetGroup'
Properties:
CacheSubnetGroupName: !Sub '${Prefix}-cache-subnetgroup'
Description: !Sub '${Prefix} Subnet Group'
SubnetIds:
- !Ref PublicSubnet1
- !Ref PublicSubnet2
ElastiCacheCluster:
Type: AWS::ElastiCache::CacheCluster
Properties:
Engine: redis
EngineVersion: "5.0.6"
CacheNodeType: !Ref ElastiCacheNodeType
ClusterName : !Sub '${Prefix}-redis'
NumCacheNodes: 1
CacheSubnetGroupName: !Ref ElastiCacheSubnetGroup
CacheParameterGroupName: 'default.redis5.0'
VpcSecurityGroupIds:
- !GetAtt RedisSecurityGroup.GroupId
Port: 6379
Tags:
- Key: Name
Value: !Sub '${Prefix}-redis'
###########################################
#
# Monitoring Instance
#
###########################################
MonitoringServerEC2:
Type: 'AWS::EC2::Instance'
Properties:
SubnetId: !Ref PublicSubnet1
ImageId: !FindInMap [ "AWSRegion2AMI", !Ref AWS::Region, "MonitoringServerAmi"]
InstanceType: !Ref InstanceTypeMonitoringServer
SecurityGroupIds:
- Ref: SshSecurityGroup
- Ref: MonitoringSecurityGroup
KeyName: !Ref KeyName
Monitoring: true
UserData:
Fn::Base64: |
#!/bin/bash -xe
# restart heplify-server
sudo systemctl restart heplify-server.service
sudo systemctl restart cassandra.service
sleep 60
sudo systemctl restart jaeger-collector.service
sudo systemctl restart jaeger-query.service
Tags:
-
Key: Name
Value: !Sub '${Prefix}-monitoring-server'
###########################################
# New SBC SIP instances
# Create a couple of EIPs for SBC SIP Servers, and tag them as such
# Note: devops can create more EIPs later, the Environment tag
# is what caused them to get associated when sip servers scale.
# The idea is simply to have a pre-allocated set of N EIPs
# for sip signaling so these can be whitelisted with carriers
###########################################
SbcSipServerEIP1:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
Tags:
-
Key: Environment
Value: !Sub '${Prefix}-sbc-sip'
-
Key: Name
Value: !Sub '${Prefix}-sbc-sip-1'
SbcSipServerEIP2:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
Tags:
-
Key: Environment
Value: !Sub '${Prefix}-sbc-sip'
-
Key: Name
Value: !Sub '${Prefix}-sbc-sip-2'
# --- SIP server EC2 IAM role
SbcSipServerIamRole:
Type: AWS::IAM::Role
Properties:
Description: SBC RTP EC2 service role
RoleName: !Sub '${Prefix}-sbc-sip-ec2-role'
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [ec2.amazonaws.com]
Action: ['sts:AssumeRole']
Path: /
Policies:
- PolicyName: root
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- 'cloudwatch:PutMetricData'
- 'ec2:DescribeVolumes'
- 'ec2:DescribeTags'
- 'logs:PutLogEvents'
- 'logs:DescribeLogStreams'
- 'logs:DescribeLogGroups'
- 'logs:CreateLogStream'
- 'logs:CreateLogGroup'
Resource: '*'
- Effect: Allow
Action:
- 'ssm:GetParameter'
Resource: 'arn:aws:ssm:*:*:parameter/AmazonCloudWatch-*'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSNSFullAccess
- arn:aws:iam::aws:policy/AutoScalingReadOnlyAccess
- arn:aws:iam::aws:policy/AmazonEC2FullAccess
# --- SIP server EC2 Role Instance profile
SbcSipServerInstanceProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
InstanceProfileName: !Sub '${Prefix}-sbc-sip-ec2-role'
Path: /
Roles:
- !Ref SbcSipServerIamRole
SbcSipConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
ImageId: !FindInMap [ "AWSRegion2AMI", !Ref AWS::Region, "SbcSipAmi"]
SecurityGroups:
- Ref: SshSecurityGroup
- Ref: SbcSipSecurityGroup
InstanceType: !Ref InstanceTypeSbcSip
IamInstanceProfile: !Ref SbcSipServerInstanceProfile
KeyName: !Ref KeyName
AssociatePublicIpAddress: true
UserData:
Fn::Base64:
Fn::Sub:
- |
#!/bin/bash
echo "running jambonz user data script"
PRE_PUBLIC_IP=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`
echo "before retrieving EIP for SIP server, public IP is $PRE_PUBLIC_IP"
/usr/local/bin/auto-assign-elastic-ip.sh
sleep 15
PUBLIC_IP=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`
echo "after retrieving EIP for SIP server, public IP is $PUBLIC_IP"
echo "writing /home/admin/apps/ecosystem.config.js.."
cat << EOF > /home/admin/apps/ecosystem.config.js
module.exports = {
apps : [
{
name: 'jambonz-smpp-esme',
cwd: '/home/admin/apps/jambonz-smpp-esme',
script: 'app.js',
out_file: '/home/admin/.pm2/logs/jambonz-smpp-esme.log',
err_file: '/home/admin/.pm2/logs/jambonz-smpp-esme.log',
combine_logs: true,
instance_var: 'INSTANCE_ID',
exec_mode: 'fork',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
JAMBONES_LOGLEVEL: 'info',
JAMBONES_CLUSTER_ID: '${JAMBONES_CLUSTER_ID}',
AVOID_UDH: true,
JAMBONES_MYSQL_REFRESH_TTL: ${DbCachingTTS},
JAMBONES_MYSQL_HOST: '${JAMBONES_MYSQL_HOST}',
JAMBONES_MYSQL_USER: '${JAMBONES_MYSQL_USER}',
JAMBONES_MYSQL_PASSWORD: '${JAMBONES_MYSQL_PASSWORD}',
JAMBONES_MYSQL_DATABASE: 'jambones',
JAMBONES_MYSQL_CONNECTION_LIMIT: 10,
JAMBONES_REDIS_HOST: '${JAMBONES_REDIS_HOST}',
JAMBONES_REDIS_PORT: 6379,
HTTP_PORT: 3020
}
},
{
name: 'sbc-sip-sidecar',
cwd: '/home/admin/apps/sbc-sip-sidecar',
script: 'app.js',
instance_var: 'INSTANCE_ID',
out_file: '/home/admin/.pm2/logs/sbc-sip-sidecar.log',
err_file: '/home/admin/.pm2/logs/sbc-sip-sidecar.log',
exec_mode: 'fork',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
JAMBONES_LOGLEVEL: 'info',
JWT_SECRET: '${JWT_SECRET}',
JAMBONES_CLUSTER_ID: '${JAMBONES_CLUSTER_ID}',
RTPENGINE_PING_INTERVAL: 30000,
DRACHTIO_HOST: '127.0.0.1',
DRACHTIO_PORT: 9022,
DRACHTIO_SECRET: 'cymru',
JAMBONES_MYSQL_REFRESH_TTL: ${DbCachingTTS},
JAMBONES_MYSQL_HOST: '${JAMBONES_MYSQL_HOST}',
JAMBONES_MYSQL_USER: '${JAMBONES_MYSQL_USER}',
JAMBONES_MYSQL_PASSWORD: '${JAMBONES_MYSQL_PASSWORD}',
JAMBONES_MYSQL_DATABASE: 'jambones',
JAMBONES_MYSQL_CONNECTION_LIMIT: 10,
JAMBONES_REDIS_HOST: '${JAMBONES_REDIS_HOST}',
JAMBONES_REDIS_PORT: 6379,
JAMBONES_TIME_SERIES_HOST: '${JAMBONES_TIME_SERIES_HOST}',
ENABLE_METRICS: 1,
STATS_HOST: '127.0.0.1',
STATS_PORT: 8125,
STATS_PROTOCOL: 'tcp',
STATS_TELEGRAF: 1,
STATS_SAMPLE_RATE: ${JAMBONES_SAMPLE_RATE},
JAMBONES_NETWORK_CIDR: '${VPC_CIDR}'
}
},
{
name: 'sbc-call-router',