-
Notifications
You must be signed in to change notification settings - Fork 59
/
stack.yaml
4064 lines (3814 loc) · 159 KB
/
stack.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'
Description: |
Hubs Cloud: Private Social VR in your web browser. Your own self-hosted hub powered by Hubs by Mozilla. Full documentation: https://github.com/mozilla/hubs-cloud Version 1.1.6
Transform: "AWS::Serverless-2016-10-31"
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Account Configuration
Parameters:
- AdminEmailAddress
- Label:
default: Domain Configuration
Parameters:
- DomainName
- IsDomainOnRoute53
- InternalZone
- ShortlinkZone
- Label:
default: Email Configuration
Parameters:
- EmailZone
- EmailSubdomain
- Label:
default: Server Configuration
Parameters:
- SpecifyInboundCidr
- KeyPair
- SpecifyInboundSSHCidr
- AppInstanceCount
- StreamInstanceCount
- AppInstanceType
- StreamInstanceType
- Label:
default: Cost Management
Parameters:
- DatabaseMonthlyBudget
- MaxStorage
- Label:
default: Offline Mode
Parameters:
- StackOffline
- StackOfflineRedirectUrl
- Label:
default: Database Configuration
Parameters:
- AutoPauseDb
- DbBackupRetentionPeriod
- DbMaxCapacity
- Label:
default: Restore from Backup
Parameters:
- RestoreStackName
- RestoreDbSnapshotIdentifier
- RestoreAppDbSecretArn
- RestoreBackupVaultName
- RestoreRecoveryPointArn
- Label:
default: SSL Certificates
Parameters:
- UnmanagedDomainCertArn
- UnmanagedDomainEastCertArn
- LetsEncryptEmailAddress
- Label:
default: Advanced - Leave these alone unless you know what you're doing!
Parameters:
- InboundCidrOverride
- InboundSSHCidrOverride
- LoadBalancingMethod
- NewCMKForDiskEncryption
- SubnetAZs
- ClassB
- AppPlacementGroupStrategy
ParameterLabels:
DomainName:
default: Domain Name
IsDomainOnRoute53:
default: Is your domain set up on Route 53?
ShortlinkZone:
default: Short link domain name
InternalZone:
default: Internal domain name
EmailZone:
default: Outgoing Email Domain
EmailSubdomain:
default: Outgoing Email Subdomain Prefix
AdminEmailAddress:
default: Administrator Email Address
LetsEncryptEmailAddress:
default: Let's Encrypt Contact Email Address (Optional)
UnmanagedDomainCertArn:
default: Non-Route 53 Domain SSL Certificate ARN
UnmanagedDomainEastCertArn:
default: Non-Route 53 Domain US-East-1 (N. Virginia) SSL Certificate ARN
AppInstanceCount:
default: Number of app servers
AppInstanceType:
default: App server EC2 instance type
StreamInstanceCount:
default: Number of voice/videos streaming servers
StreamInstanceType:
default: Voice/video streaming server EC2 instance type
ClassB:
default: Class B IP Block
NewCMKForDiskEncryption:
default: Create a dedicated CMK for database and backup encryption?
AppPlacementGroupStrategy:
default: App server placement group strategy
DbBackupRetentionPeriod:
default: "Database backup retention period (in days)"
DbMaxCapacity:
default: "Max database capacity (in ACUs)"
RestoreDbSnapshotIdentifier:
default: "Restore From Database Snapshot Identifier"
RestoreAppDbSecretArn:
default: "Restore From Database Secret ARN"
RestoreStackName:
default: "Restore From Stack Name"
RestoreBackupVaultName:
default: "Restore From Vault Name"
RestoreRecoveryPointArn:
default: "Restore From Recovery Point ARN"
LoadBalancingMethod:
default : "Load Balancing Method"
AutoPauseDb:
default : "Auto-Pause Database"
SubnetAZs:
default : "Subnet Availability Zones"
StackOffline:
default: "Stack Mode"
StackOfflineRedirectUrl:
default: "Offline Redirect URL (Optional)"
DatabaseMonthlyBudget:
default: "Account Monthly Database Budget (US dollars, no $ and no cents)"
MaxStorage:
default: "Storage Limit (in GB)"
InboundCidrOverride:
default: "Inbound Site Access CIDR"
InboundSSHCidrOverride:
default: "Inbound SSH CIDR"
SpecifyInboundCidr:
default: "Restrict Site Access"
SpecifyInboundSSHCidr:
default: "Restrict SSH Access"
Parameters:
DomainName:
Type: String
Description: Domain name your hub will be hosted on. (eg myhub.com or hub.mydomain.com.) This should be a domain you already own, either on a third party provider (eg GoDaddy or Namecheap) or on AWS Route 53.
AllowedPattern: ^((?:([a-z0-9]\.|[a-z0-9][a-z0-9\-]{0,61}[a-z0-9])\.)+)([a-z0-9]{2,63}|(?:[a-z0-9][a-z0-9\-]{0,61}[a-z0-9]))\.?$
ConstraintDescription: Must be a valid domain name (eg myhub.com or hub.mycompany.com)
IsDomainOnRoute53:
Type: String
Description: We recommended you use Route 53 to manage your domain. Set to Yes if your domain is set up on Route 53, and you can move onto the next item. Set to No if your domain is on a third party service such as GoDaddy or Namecheap. If you choose 'No', you'll need to set the fields in 'Custom SSL Certificates' below. Also, if you choose 'No', once your stack is created you'll need to update your DNS provider using the 'AddressForRootDomain' information in the 'Outputs' tab. See the 'Outputs' tab once the stack is created for more information on what to do next.
AllowedValues: ["Yes - My domain is set up on Route 53", "No - My domain is not on Route 53 and I will set up my SSL certificate below in the 'SSL Certificates' section"]
ShortlinkZone:
Type: AWS::Route53::HostedZone::Id
Description: You'll need a Route 53 domain name for short room permalinks, entry codes, and device linking. (eg myhub.link) It should *not* be the same domain as the any of the domain names that you specified above. This domain will be used by visitors to share room links, and ideally should be short and easy to type since it will be typed by users on mobile devices and in VR.
AllowedPattern: ".+"
ConstraintDescription: You didn't specify a short link Route 53 Zone. Please choose one or create a new domain name on AWS on Route 53, ideally one short and easy to type.
InternalZone:
Type: AWS::Route53::HostedZone::Id
Description: Your hub needs a domain name to use internally for server management. If your primary domain is on Route 53 and you're not using it for anything else, you can choose it here. Otherwise, you'll need to register a new domain name on Route 53 for this (for example, myhub-internal.com). This domain name will not be seen by users.
AllowedPattern: ".+"
ConstraintDescription: You didn't specify an internal Route 53 Zone. Please choose one or create a new domain name on AWS on Route 53. It can be anything you want and is used internally. It will not be seen by your visitors.
EmailZone:
Type: AWS::Route53::HostedZone::Id
Description: To verify email addresses, your hub needs to be able to send email. If you do not have an existing email SMTP provider, choose a Route 53 domain you'd like to send email from. It will be set up automatically using AWS Simple Email Service. If you have an existing email provider you'd like to send email from (eg Mailchimp) or already have a verified domain in AWS Simple Email Service select the same zone you chose above for 'Internal Route 53 Zone' and you'll be able to enter the login credentials from your email provider later.
AllowedPattern: ".+"
ConstraintDescription: You didn't specify an Route 53 Zone to send email from. Please choose one. If you already have email set up, just choose your Internal Route 53 Zone.
EmailSubdomain:
Type: String
Description: The Subdomain prefix to use for outgoing emails. For example, if your Outgoing Email Route 53 Zone is set to myhub.com, setting this field to "mail" will send email from the domain mail.myhub.com. If you have a third party email provider (eg Mailchimp) you can ignore this field.
Default: mail
AdminEmailAddress:
Type: String
Description: Email address for your administrator account. Individuals with access to this email address will have full administrative control of your hub. Before you can log in, you will need to verify this email address - you will get a verification email from AWS after the stack is ready.
AllowedPattern: ".+"
ConstraintDescription: "You must enter a contact email address."
LetsEncryptEmailAddress:
Type: String
Description: Your servers will use Let's Encrypt to automatically manage SSL certificates. To receive urgent email notifications regarding your certificates from Let's Encrypt, specify a contact email here. This field is optional. By deploying this stack you agree to the LetsEncrypt TOS. (https://letsencrypt.org/repository/)
Default: None
UnmanagedDomainCertArn:
Type: String
Description: "You can skip this if your domain is on Route 53 and you chose 'Yes' above to 'Is your domain set up on Route 53?'. Otherwise, if you chose 'No' and you are using a domain name managed by another provider like GoDaddy or Namecheap you will need to create an SSL certificate in the same region as your stack in AWS Certificate Manager before completing this form. Instructions can be found at https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html. *Note* - make sure you create your SSL certificate in the AWS region you'd like to use for your hub's stack. (The region can be found in the top right corner of the AWS console.) Once you've created the certificate, paste the ARN for the certificate here (eg arn:aws:acm:<region>:<account>:certificate/<id>). You can find the ARN by clicking on the certificate in the AWS Certificate Manager console."
ConstraintDescription: You must point to an ARN in AWS Certificate Manager for your domain.
UnmanagedDomainEastCertArn:
Type: String
Description: "You can skip this if your domain is on Route 53 and you chose 'Yes' above to 'Is your domain set up on Route 53?'. Otherwise, you'll need to create a SSL certificate for your external domain in US-East-1 (N. Virginia). Instructions can be found at https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html. *Note* - make sure you provide a SSL certificate in US-East-1 regardless of what region you are creating the stack in. If you are creating your stack in US-East-1 (N. Virginia) and so already pasted a certificate ARN in US-East-1 for the above field, you can paste the same certificate ARN here. Otherwise, you'll need to create a new SSL certificate in US-East-1 and paste its ARN here. (eg arn:aws:acm:us-east-1:<account>:certificate/<id>) Be sure to change the region in the top right of the console to 'US East (N. Virginia) before creating the certificate."
ConstraintDescription: You must point to an ARN in US-East-1 (N. Virginia) AWS Certificate Manager for your domain.
AppInstanceCount:
Type: Number
Description: The number of app server(s) you'd like to run. The app servers provide all the necessary services for your hub. You must run at least one app server.
Default: 1
MinValue: 1
ConstraintDescription: You must run at least one app server.
AppInstanceType:
Type: String
Description: The EC2 instance type for your app server(s). Choose a "t" instance type if you expect bursty use of the service, and the "c" types if you expect steady usage.
Default: c4.large
AllowedValues:
- t3.micro
- t3.small
- t3.medium
- t3.large
- t3.xlarge
- t3.2xlarge
- c4.large
- c5.large
- c5.xlarge
- c5.2xlarge
- c5.4xlarge
- c5.9xlarge
- c5.12xlarge
- c5.18xlarge
- c5.24xlarge
StreamInstanceCount:
Type: Number
Description: The number of dedicated voice/video streaming server(s) you'd like to run. These servers are optional - enter a zero here if you do not want to run any streaming servers. Adding streaming servers will take network and CPU load off of your app servers. These servers will transmit voice and streaming video data between users.
Default: 0
MinValue: 0
StreamInstanceType:
Type: String
Description: The EC2 instance type for your streaming server(s), if you've added any. This field will not be used if you entered zero for the number of streaming servers. Choose a "t" instance type if you expect bursty use of the service, and the "c" types if you expect steady usage.
Default: c4.large
AllowedValues:
- t3.micro
- t3.small
- t3.medium
- t3.large
- t3.xlarge
- t3.2xlarge
- c4.large
- c5.large
- c5.xlarge
- c5.2xlarge
- c5.4xlarge
- c5.9xlarge
- c5.12xlarge
- c5.18xlarge
- c5.24xlarge
KeyPair:
Type: AWS::EC2::KeyPair::KeyName
Description: "SSH Keypair for server SSH access. If there no keypairs in this list, you'll need to add a SSH keypair via the EC2 console. See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#having-ec2-create-your-key-pair."
AllowedPattern: ".+"
ConstraintDescription: "You must choose an SSH keypair. To create one, see: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#having-ec2-create-your-key-pair."
ClassB:
Type: String
Description: VPC ClassB (10.XX.0.0/16) block to use for internal server IPs.
Default: 0
AppPlacementGroupStrategy:
Type: String
Description: "Placement group strategy for app servers. If you only have one app server, this setting has no effect. If you have more than one app server, choose 'cluster' to increase connectivity between servers at the cost of reliability. When using 'cluster', you will have lower latency between users but your service will go down if there is an AZ-wide outage. Choose 'spread' if you would like to ensure higher availability at the cost of latency or maximum throughput between app servers. Choose 'none' if you do not have a preference, will be running more than 7 app servers, or if AWS has been failing to provision servers for you in previous attempts to create the stack. App servers communicate with one another extensively, so 'cluster' is the preferred setting if you can tolerate some risk of downtime if there are AZ-wide outages, which are rare."
Default: cluster
AllowedValues:
- cluster
- spread
- none
DbBackupRetentionPeriod:
Type: Number
Description: "Number of days your AWS Aurora database backups will be retained for."
Default: 14
DbMaxCapacity:
Type: Number
Description: "Maximum ACU Capacity for the database. If you are unsure, leave this at the default. The database will be a serverless Aurora PostgreSQL-compatible cluster. Increasing the Maximum ACUs will increase the available resources to your hub for database queries, but will cost more. This needs to be set to at least 2. Pricing info for ACUs can be found at https://aws.amazon.com/rds/aurora/serverless/"
MinValue: 2
MaxValue: 384
Default: 2
RestoreDbSnapshotIdentifier:
Type: String
Description: "Leave blank if you are not restoring from a backup. To restore from an existing backup, specify the AWS Aurora database snapshot identifier to restore from. (eg mystack-snapshot-mystack-app-db-xxxxx) WARNING: do *not* change or blank out this value after your stack is created, otherwise you will replace your existing database!"
RestoreAppDbSecretArn:
Type: String
Description: "Leave blank if you are not restoring from a backup. To restore from an existing backup, specify the ARN for the database secret from the hub being restored from. (eg arn:aws:secretsmanager:<region>:<account-id>:secret:AppDbSecret-xxxxxxxxx) WARNING: do *not* change or blank out this value after your stack is created, otherwise you will replace your existing database!"
RestoreStackName:
Type: String
Description: "Leave blank if you are not restoring from a backup. To restore from an existing backup, specify the stack name being restored from. To restore, the secrets stored in Parameter Store must still be available from the stack being restored from. These parameters should still exist even if you deleted the old stack, unless you manually removed them. WARNING: do *not* change or blank out this value after your stack is created, otherwise you will replace your existing database!"
RestoreBackupVaultName:
Type: String
Description: "Leave blank if you are not restoring from a backup. To restore from an existing backup, specify the AWS Backup Vault Name to restore storage from. (eg mystack-daily-backup-xxxxxxx) WARNING: do *not* change or blank out this value after your stack is created, otherwise you will replace your existing database!"
RestoreRecoveryPointArn:
Type: String
Description: "Leave blank if you are not restoring from a backup. To restore from an existing backup, specify the AWS Backup Vault's Recovery Point ARN to restore storage from. (eg arn:aws:backup:<region>:<account id>:recovery-point:xxxxxxxx) WARNING: do *not* change or blank out this value after your stack is created, otherwise you will replace your existing database!"
NewCMKForDiskEncryption:
Type: String
Description: "Select 'Yes' if you'd like to create a dedicated CMK in KMS for database and backup encryption. KMS charges for a single managed key will apply."
Default: "No - Use the AWS Managed Key"
AllowedValues:
- No - Use the AWS Managed Key
- Yes - Create a new CMK
SubnetAZs:
Type: String
Description: "If your stack is failing to create, and the 'Events' tab shows the error 'Value (xxx) for parameter availabilityZone is invalid. Subnets can currently only be created in the following availability zones: X, Y', you will need to select an alternative subnet configuration here. This is an issue with AWS: https://github.com/widdix/aws-cf-templates/issues/36"
Default: "Use zone a and b"
AllowedValues:
- Use zone a and b
- Use zone b and c
- Use zone a and c
- Use zone b and d
- Use zone c and d
LoadBalancingMethod:
Type: String
Description: Method for load balancing requests to app servers. If you only have one or a few app servers, and would like to save on AWS costs, choose DNS Round Robin. If you have several app servers or would like improved load balancing, you can also use an Application Load Balancer, which will incur additional costs. If you are using a domain not on Route 53, be sure to note the "AddressForRootDomain" in the Outputs tab after the stack update to set your DNS to point to the ALB.
Default: "Application Load Balancer"
AllowedValues: ["DNS Round Robin", "Application Load Balancer"]
AutoPauseDb:
Type: String
Description: Your hub uses the Aurora Serverless database, which can greatly save costs by pausing the database when your hub is not in use. However, when the database is paused, it can take up to 20 seconds for your site to come back up when you visit it. You can turn off database pausing if you'd like to avoid any delay in loading your site. Turning off pausing will incur continuous hourly database costs. Pricing info can be found at https://aws.amazon.com/rds/aurora/serverless/
Default: "No - Pay for database continuously to prevent loading delays"
AllowedValues: ["Yes - Pause database when not in use", "No - Pay for database continuously to prevent loading delays"]
StackOffline:
Type: String
Description: To save costs, you can switch your stack from being Online to Offline when it is not needed. This will shut down the servers while keeping all of your data. Once your stack is switched back to Online, it will come back up just how you left it.
AllowedValues: ["Online", "Offline - Temporarily shut off servers"]
Default: "Online"
StackOfflineRedirectUrl:
Type: String
Description: (Optional) When your stack is set to Offline, visitors will be redirected to this URL.
DatabaseMonthlyBudget:
Type: Number
Description: If you do not want a monthly database budget, set this to zero. To save costs, your AWS Aurora Serverless database will be shut down when nobody is hitting your site. When visitors are using your site, you'll incur database costs. To avoid unexpected charges, you can set a monthly budget. If you are running multiple hubs, this budget should reflect your maximum allowed cost across *all* your hubs in this region. This hub will automatically switch into Offline mode if the Aurora Serverless database charges across all your hubs in this region exceed this budget. A minimum $20 budget is recommended and will provide more than 40 hours a week of connectivity for a hub. You only pay for what you use. Leave this field blank to fall back to your "Max database capacity" setting in "Database Configuration" to limit your database cost. Pricing info can be found at https://aws.amazon.com/rds/aurora/serverless/
Default: 0
MaxStorage:
Type: Number
Description: When users upload scenes, avatars, or files, they will use disk storage. You only pay for the storage you use. You can set a maximum storage amount here (in GB) to ensure there are no unexpected charges. Pricing info can be found at https://aws.amazon.com/efs/pricing/
MinValue: 5
MaxValue: 1048576
Default: 1024
InboundCidrOverride:
Type: String
Description: IP CDIR which will be granted HTTPS and WebRTC access to your site. Set to 0.0.0.0/0 to allow anyone on the Internet to access your site.
InboundSSHCidrOverride:
Type: String
Description: IP CDIR which will be granted SSH port access to your servers. Connecting users will still need valid SSH keys to access your server. Set to 0.0.0.0/0 to allow any IP with the SSH key + 2FA token to access your servers via SSH.
SpecifyInboundCidr:
Type: String
Description: You can restrict which IP addresses can access your site. To allow anyone on the Internet to load your site, choose 'Allow anyone to access my site.'
AllowedValues: ["Allow anyone to access my site", "I will specify the 'Inbound Site Access CDIR' in 'Advanced' below to restrict IP addresses to my site"]
Default: "Allow anyone to access my site"
SpecifyInboundSSHCidr:
Type: String
Description: You can restrict the IP addresses that can access your servers over SSH. SSH access will always require the SSH private key file specified above and the 2FA token regardless of IP.
AllowedValues: ["Allow anyone with the SSH secret key and 2FA token to access my servers", "I will specify the 'Inbound SSH CDIR' in 'Advanced' below to restrict SSH IP addresses to my servers"]
AllowedPattern: ".+"
ConstraintDescription: "You must select if you'd like any IP SSH restrictions."
Mappings:
Regions:
us-east-1:
Abbreviation: USE1
us-west-1:
Abbreviation: USW1
us-west-2:
Abbreviation: USW2
us-east-2:
Abbreviation: USE2
ap-northeast-1:
Abbreviation: APN1
eu-west-1:
Abbreviation: EU
ServicesMeta:
RetExternal:
Port: 443
RetInternal:
Port: 4000
RetTurnExternal:
Port: 5349
DialogInternal:
Port: 8443
DialogExternal:
AppPort: 8443
StreamPort: 443
DialogTurnExternal:
Port: 5349
DialogAdmin:
Port: 7000
DialogWebRTCFrom:
Port: 51610
DialogWebRTCTo:
Port: 60999
YTDL:
Port: 8080
BioCensus:
Port: 9631
Ssh:
Port: 22
PostgreSQL:
Port: 5432
InstanceTypeMeta:
# Some instance types do not support cluster placement, so use spread
t3.micro:
PlacementForCluster: spread
t3.small:
PlacementForCluster: spread
t3.medium:
PlacementForCluster: spread
t3.large:
PlacementForCluster: spread
t3.xlarge:
PlacementForCluster: spread
t3.2xlarge:
PlacementForCluster: spread
c4.large:
PlacementForCluster: cluster
c5.large:
PlacementForCluster: cluster
c5.xlarge:
PlacementForCluster: cluster
c5.2xlarge:
PlacementForCluster: cluster
c5.4xlarge:
PlacementForCluster: cluster
c5.9xlarge:
PlacementForCluster: cluster
c5.12xlarge:
PlacementForCluster: cluster
c5.18xlarge:
PlacementForCluster: cluster
c5.24xlarge:
PlacementForCluster: cluster
Conditions:
HasManagedDomain: !Equals [!Ref IsDomainOnRoute53, "Yes - My domain is set up on Route 53"]
HasInboundCidrOverride: !Equals [!Ref SpecifyInboundCidr, "I will specify the 'Inbound Site Access CDIR' in 'Advanced' below to restrict IP addresses to my site"]
HasInboundSSHCidrOverride: !Equals [!Ref SpecifyInboundSSHCidr, "I will specify the 'Inbound SSH CDIR' in 'Advanced' below to restrict SSH IP addresses to my servers"]
HasUnmangedDomain: !Not [Condition: HasManagedDomain]
HasLetsEncryptEmail: !Not [!Equals [!Ref LetsEncryptEmailAddress, "None"]]
HasStreamingServers: !And [!Equals [!Ref StackOffline, "Online"], !Not [!Equals [!Ref StreamInstanceCount, 0]]]
AppIsNoPlacement: !Equals [!Ref AppPlacementGroupStrategy, none]
AppIsClusterPlacement: !Equals [!Ref AppPlacementGroupStrategy, cluster]
HasEmailSubdomain: !Not [!Equals [!Ref EmailSubdomain, ""]]
CreateDiskEncryptionKey: !Equals [!Ref NewCMKForDiskEncryption, "Yes - Create a new CMK"]
SubnetChoiceA: !Equals [!Ref SubnetAZs, "Use zone a and b"]
SubnetChoiceB: !Equals [!Ref SubnetAZs, "Use zone b and c"]
SubnetChoiceC: !Equals [!Ref SubnetAZs, "Use zone a and c"]
SubnetChoiceD: !Equals [!Ref SubnetAZs, "Use zone b and d"]
IsOnline: !Equals [!Ref StackOffline, "Online"]
IsOffline: !Not [Condition: IsOnline]
HasOfflineRedirectUrl: !Not [!Equals [!Ref StackOfflineRedirectUrl, ""]]
PerformOfflineRedirect: !And [ Condition: IsOffline, Condition: HasOfflineRedirectUrl ]
PerformOfflineRedirectWithUnmanagedDomain: !And [Condition: PerformOfflineRedirect, Condition: HasUnmangedDomain]
EnableDbAutoPause: !Equals [!Ref AutoPauseDb, "Yes - Pause database when not in use"]
HasDbMonthlyBudget: !Not [!Equals [!Ref DatabaseMonthlyBudget, 0]]
IsNotRestore: !Equals [!Ref RestoreDbSnapshotIdentifier, ""]
IsRestore: !Not [Condition: IsNotRestore]
IsEast: !Equals [!Sub "${AWS::Region}", "us-east-1"]
IsNonEast: !Not [Condition: IsEast]
HasManagedDomainNonEast: !And [Condition: IsNonEast, Condition: HasManagedDomain]
HasManagedDomainEast: !And [Condition: IsEast, Condition: HasManagedDomain]
# NOTE: keep the ALB around if we are doing an offline redirect *and* we have an unmanaged domain, because otherwise
# it would require the user to go update their external DNS CNAME to get the redirect to work. The downside is that
# for this specific scenario the user will continue to pay for the ALB.
RequestedALB: !Equals [!Ref LoadBalancingMethod, "Application Load Balancer"]
HasALB: !And [!Or [Condition: IsOnline, Condition: PerformOfflineRedirectWithUnmanagedDomain], Condition: RequestedALB]
Resources:
# VPC - Two subnets for public + private
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Sub '10.${ClassB}.0.0/16'
EnableDnsSupport: true
EnableDnsHostnames: true
InstanceTenancy: default
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} 10.${ClassB}.0.0/16'
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} 10.${ClassB}.0.0/16'
VPCGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway
SubnetAPublic:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [!If [SubnetChoiceA, 0, !If [SubnetChoiceB, 1, !If [SubnetChoiceC, 0, !If [SubnetChoiceD, 1, 2]]]], !GetAZs '']
CidrBlock: !Sub '10.${ClassB}.0.0/20'
MapPublicIpOnLaunch: true
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} A public'
- Key: Reach
Value: public
SubnetAPrivate:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [!If [SubnetChoiceA, 0, !If [SubnetChoiceB, 1, !If [SubnetChoiceC, 0, !If [SubnetChoiceD, 1, 2]]]], !GetAZs '']
CidrBlock: !Sub '10.${ClassB}.16.0/20'
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} A private'
- Key: Reach
Value: private
SubnetBPublic:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [!If [SubnetChoiceA, 1, !If [SubnetChoiceB, 2, !If [SubnetChoiceC, 2, !If [SubnetChoiceD, 3, 3]]]], !GetAZs '']
CidrBlock: !Sub '10.${ClassB}.32.0/20'
MapPublicIpOnLaunch: true
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} B public'
- Key: Reach
Value: public
SubnetBPrivate:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Select [!If [SubnetChoiceA, 1, !If [SubnetChoiceB, 2, !If [SubnetChoiceC, 2, !If [SubnetChoiceD, 3, 3]]]], !GetAZs '']
CidrBlock: !Sub '10.${ClassB}.48.0/20'
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} B private'
- Key: Reach
Value: private
RouteTableAPublic:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} A public'
RouteTableAPrivate:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} A private'
RouteTableBPublic:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} B public'
RouteTableBPrivate:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} B private'
RouteTableAssociationAPublic:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref SubnetAPublic
RouteTableId: !Ref RouteTableAPublic
RouteTableAssociationAPrivate:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref SubnetAPrivate
RouteTableId: !Ref RouteTableAPrivate
RouteTableAssociationBPublic:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref SubnetBPublic
RouteTableId: !Ref RouteTableBPublic
RouteTableAssociationBPrivate:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref SubnetBPrivate
RouteTableId: !Ref RouteTableBPrivate
RouteTablePublicAInternetRoute:
Type: AWS::EC2::Route
DependsOn: VPCGatewayAttachment
Properties:
RouteTableId: !Ref RouteTableAPublic
DestinationCidrBlock: '0.0.0.0/0'
GatewayId: !Ref InternetGateway
RouteTablePublicBInternetRoute:
Type: AWS::EC2::Route
DependsOn: VPCGatewayAttachment
Properties:
RouteTableId: !Ref RouteTableBPublic
DestinationCidrBlock: '0.0.0.0/0'
GatewayId: !Ref InternetGateway
NetworkAclPublic:
Type: AWS::EC2::NetworkAcl
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} Public'
NetworkAclPrivate:
Type: AWS::EC2::NetworkAcl
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub '${AWS::StackName} Private'
SubnetNetworkAclAssociationAPublic:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !Ref SubnetAPublic
NetworkAclId: !Ref NetworkAclPublic
SubnetNetworkAclAssociationAPrivate:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !Ref SubnetAPrivate
NetworkAclId: !Ref NetworkAclPrivate
SubnetNetworkAclAssociationBPublic:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !Ref SubnetBPublic
NetworkAclId: !Ref NetworkAclPublic
SubnetNetworkAclAssociationBPrivate:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !Ref SubnetBPrivate
NetworkAclId: !Ref NetworkAclPrivate
NetworkAclEntryInPublicAllowAll:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref NetworkAclPublic
RuleNumber: 99
Protocol: -1
RuleAction: allow
Egress: false
CidrBlock: '0.0.0.0/0'
NetworkAclEntryOutPublicAllowAll:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref NetworkAclPublic
RuleNumber: 99
Protocol: -1
RuleAction: allow
Egress: true
CidrBlock: '0.0.0.0/0'
NetworkAclEntryInPrivateAllowVPC:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref NetworkAclPrivate
RuleNumber: 99
Protocol: -1
RuleAction: allow
Egress: false
CidrBlock: '0.0.0.0/0'
NetworkAclEntryOutPrivateAllowVPC:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref NetworkAclPrivate
RuleNumber: 99
Protocol: -1
RuleAction: allow
Egress: true
CidrBlock: '0.0.0.0/0'
## route53dependency
Route53DependencyLambda:
Metadata:
Source: https://github.com/sonyxperiadev/amazon-custom-resources/tree/master/route53-dependency
Version: 1.0.0
Type: AWS::Lambda::Function
Properties:
FunctionName: !Sub "${AWS::StackName}-route53-dependency"
Description: Lookup Route 53 info
Handler: index.handler
Role: !GetAtt Route53DependencyRole.Arn
Runtime: nodejs14.x
Timeout: 900
Code:
ZipFile: |
'use strict';
function route53Dependency(properties, callback) {
if (!properties.Id && !properties.Domain)
callback("Zone id or domain not specified");
var aws = require("aws-sdk");
var route53 = new aws.Route53();
var responseData = {};
console.log('route53Dependency', properties);
route53.listHostedZones({}, function(err, data) {
console.log('listHostedZones', err, data);
if (err)
return callback(err);
var zones = data.HostedZones;
var matching = zones.filter(function(zone) {
if (properties.Id) {
return zone.Id === "/hostedzone/" + properties.Id;
} else {
var tldParts = properties.Domain.split(".");
var tld = tldParts[tldParts.length - 2] + "." + tldParts[tldParts.length - 1];
return zone.Name === tld + ".";
}
});
if (matching.length != 1)
return callback('Exactly one matching zone is allowed ' + zones);
var match = matching[0];
delete match.Config;
delete match.CallerReference;
match.Id = match.Id.split('/')[2];
match.Name = match.Name.substring(0, match.Name.length-1);
return callback(null, match);
});
}
route53Dependency.handler = function(event, context) {
console.log(JSON.stringify(event, null, ' '));
if (event.RequestType == 'Delete') {
return sendResponse(event, context, "SUCCESS");
}
route53Dependency(event.ResourceProperties, function(err, result) {
var status = err ? 'FAILED' : 'SUCCESS';
return sendResponse(event, context, status, result, err);
});
};
function getReason(err) {
if (err)
return err.message;
else
return '';
}
function sendResponse(event, context, status, data, err) {
var responseBody = {
StackId: event.StackId,
RequestId: event.RequestId,
LogicalResourceId: event.LogicalResourceId,
PhysicalResourceId: 'route53Dependency-' + (event.ResourceProperties.Domain || event.ResourceProperties.Id),
Status: status,
Reason: getReason(err) + " See details in CloudWatch Log: " + context.logStreamName,
Data: data
};
console.log("RESPONSE:\n", responseBody);
var json = JSON.stringify(responseBody);
var https = require("https");
var url = require("url");
var parsedUrl = url.parse(event.ResponseURL);
var options = {
hostname: parsedUrl.hostname,
port: 443,
path: parsedUrl.path,
method: "PUT",
headers: {
"content-type": "",
"content-length": json.length
}
};
var request = https.request(options, function(response) {
console.log("STATUS: " + response.statusCode);
console.log("HEADERS: " + JSON.stringify(response.headers));
context.done(null, data);
});
request.on("error", function(error) {
console.log("sendResponse Error:\n", error);
context.done(error);
});
request.on("end", function() {
console.log("end");
});
request.write(json);
request.end();
}
module.exports = route53Dependency;
Route53DependencyRole:
Properties:
RoleName: !Sub "${AWS::StackName}-Route53Dependency"
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: '2012-10-17'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- arn:aws:iam::aws:policy/service-role/AWSLambdaRole
Policies:
- PolicyDocument:
Statement:
- Action:
- route53:ListHostedZones
Effect: Allow
Resource: "*"
Version: '2012-10-17'
PolicyName: !Sub '${AWS::StackName}Route53DependencyCustomPolicy'
Type: AWS::IAM::Role
# URL parsing for offline redirector
ParseURL:
Type: AWS::Lambda::Function
Properties:
FunctionName: !Sub "${AWS::StackName}-parse-url"
Description: Parse a URL into its constituent parts for redirector
Handler: index.handler
Role: !GetAtt ParseURLRole.Arn
Runtime: nodejs14.x
Timeout: 900
Code:
ZipFile: |
const URL = require('url');
const parseURL = {};
function btoa(s) {
return Buffer.from(s).toString('base64');
}
parseURL.handler = function(event, context) {
const url = event.ResourceProperties.URL || "https://en.wikipedia.org/wiki/Rubber_duck";
try {
const parsed = URL.parse(url);
const pathname = parsed.pathname;
return sendResponse(event, context, "SUCCESS", {
S3ReplaceKeyPrefixWith: `${parsed.pathname.substring(1)}${parsed.search || ""}${parsed.hash || ""}`,
S3Protocol: parsed.protocol.replace(":", ""),
S3Hostname: parsed.host,
ALBProtocol: parsed.protocol.replace(":", "").toUpperCase(),
ALBPort: parsed.port,
ALBHost: parsed.host,
ALBPath: parsed.pathname,
ALBQuery: `${parsed.search || ""}${parsed.hash || ""}`.replace(/^\?/, "")
});
} catch (e) {
return sendResponse(event, context, "FAILED", null, `Invalid URL specified: ${url}`);
}
};
function getReason(err) {
if (err)
return err.message;
else
return '';
}
function sendResponse(event, context, status, data, err) {
var responseBody = {
StackId: event.StackId,
RequestId: event.RequestId,
LogicalResourceId: event.LogicalResourceId,
PhysicalResourceId: 'parseUrl-' + btoa(event.ResourceProperties.URL),
Status: status,
Reason: getReason(err) + " See details in CloudWatch Log: " + context.logStreamName,
Data: data
};
console.log("RESPONSE:\n", responseBody);
var json = JSON.stringify(responseBody);
var https = require("https");
var url = require("url");
var parsedUrl = url.parse(event.ResponseURL);
var options = {
hostname: parsedUrl.hostname,
port: 443,
path: parsedUrl.path,
method: "PUT",
headers: {
"content-type": "",
"content-length": json.length
}
};
var request = https.request(options, function(response) {
console.log("STATUS: " + response.statusCode);
console.log("HEADERS: " + JSON.stringify(response.headers));
context.done(null, data);
});
request.on("error", function(error) {
console.log("sendResponse Error:\n", error);
context.done(error);
});
request.on("end", function() {
console.log("end");
});
request.write(json);
request.end();
}
module.exports = parseURL;
ParseURLRole:
Properties:
RoleName: !Sub "${AWS::StackName}-ParseURLRole"
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: '2012-10-17'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- arn:aws:iam::aws:policy/service-role/AWSLambdaRole
Type: AWS::IAM::Role
ToLower:
Type: AWS::Lambda::Function
Properties:
FunctionName: !Sub "${AWS::StackName}-to-lower"
Description: Convert a string to lower
Handler: index.handler
Role: !GetAtt ToLowerRole.Arn
Runtime: nodejs14.x
Timeout: 900
Code:
ZipFile: |
const toLower = {};
function btoa(s) {
return Buffer.from(s).toString('base64');
};
function getReason(err) {
if (err)
return err.message;
else
return '';
};
toLower.handler = function(event, context) {
return sendResponse(event, context, "SUCCESS", { Value: event.ResourceProperties.String.toLowerCase() });
};
function sendResponse(event, context, status, data, err) {
var responseBody = {
StackId: event.StackId,
RequestId: event.RequestId,
LogicalResourceId: event.LogicalResourceId,
PhysicalResourceId: 'toLower-' + btoa(event.ResourceProperties.String),
Status: status,
Reason: getReason(err) + " See details in CloudWatch Log: " + context.logStreamName,
Data: data
};
console.log("RESPONSE:\n", responseBody);
var json = JSON.stringify(responseBody);
var https = require("https");
var url = require("url");
var parsedUrl = url.parse(event.ResponseURL);
var options = {
hostname: parsedUrl.hostname,
port: 443,
path: parsedUrl.path,
method: "PUT",
headers: {
"content-type": "",
"content-length": json.length
}
};
var request = https.request(options, function(response) {
console.log("STATUS: " + response.statusCode);
console.log("HEADERS: " + JSON.stringify(response.headers));
context.done(null, data);
});
request.on("error", function(error) {
console.log("sendResponse Error:\n", error);
context.done(error);
});
request.on("end", function() {
console.log("end");
});
request.write(json);
request.end();
}
module.exports = toLower;
ToLowerRole:
Properties: