/
template.yaml
1234 lines (1226 loc) · 33.1 KB
/
template.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: AWS Service Broker - Amazon RDS for MariaDB (qs-1ob09h6ae)
Metadata:
AWS::ServiceBroker::Specification:
Version: 1.0
Tags:
- AWS
- RDS
- MariaDB
- database
Name: rdsmariadb
DisplayName: Amazon RDS for MariaDB
LongDescription: MariaDB is a popular open source relational database created
by the original developers of MySQL. Amazon RDS makes it easy to set up, operate,
and scale MariaDB deployments in the cloud. With Amazon RDS, you can deploy
scalable MariaDB databases in minutes with cost-efficient and resizable hardware
capacity. Amazon RDS frees you up to focus on your application by managing time-consuming
database administration tasks including backups, software patching, monitoring,
scaling and replication.
ImageUrl: https://s3.amazonaws.com/awsservicebroker/icons/AmazonRDS_LARGE.png
DocumentationUrl: https://aws.amazon.com/documentation/rds/
ProviderDisplayName: Amazon Web Services
ServicePlans:
production:
DisplayName: Production
Description: Configuration designed for production deployments
LongDescription: Creates an Amazon RDS for MariaDB database optimised for
production use
Cost: https://aws.amazon.com/rds/pricing/
ParameterValues:
MultiAZ: 'true'
NumberOfAvailabilityZones: '2'
AvailabilityZones: Auto
CidrSize: '27'
CidrBlocks: Auto
DBName: Auto
PortNumber: 13306
StorageEncrypted: 'true'
StorageType: io1
CopyTagsToSnapshot: 'true'
BackupRetentionPeriod: 35
MonitoringInterval: '1'
AllowMajorVersionUpgrade: 'false'
AutoMinorVersionUpgrade: 'true'
MasterUsername: master
MasterUserPassword: Auto
dev:
DisplayName: Development
Description: Configuration designed for development and testing deployments
LongDescription: Creates an Amazon RDS for MariaDB database optimised for
dev/test use
Cost: https://aws.amazon.com/rds/pricing/
ParameterValues:
MultiAZ: 'false'
NumberOfAvailabilityZones: '2'
AvailabilityZones: Auto
CidrSize: '28'
CidrBlocks: Auto
DBName: Auto
PortNumber: 13306
StorageEncrypted: 'true'
StorageType: io1
CopyTagsToSnapshot: 'false'
BackupRetentionPeriod: 0
MonitoringInterval: '60'
AllowMajorVersionUpgrade: 'false'
AutoMinorVersionUpgrade: 'true'
MasterUsername: master
MasterUserPassword: Auto
PreferredBackupWindow: 04:00-06:00
PreferredMaintenanceWindowDay: Sat
PreferredMaintenanceWindowStartTime: 06:00
PreferredMaintenanceWindowEndTime: 07:00
custom:
DisplayName: Custom
Description: Custom Configuration for Advanced deployments
LongDescription: Creates an Amazon RDS for MariaDB database with custom configuration
Cost: https://aws.amazon.com/rds/pricing/
ParameterValues: {}
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Database Instance Specifications
Parameters:
- DBInstanceClass
- AllocatedStorageAndIops
- Label:
default: Database Options
Parameters:
- EngineVersion
- MysqlServerTimezone
- MultiAZ
- PortNumber
- MasterUsername
- MasterUserPassword
- Label:
default: Network and Security
Parameters:
- VpcId
- PubliclyAccessible
- AccessCidr
- CidrBlocks
- CidrSize
- AvailabilityZones
- NumberOfAvailabilityZones
- Label:
default: Backup
Parameters:
- PreferredBackupWindow
- Label:
default: Maintenance
Parameters:
- PreferredMaintenanceWindowDay
- PreferredMaintenanceWindowStartTime
- PreferredMaintenanceWindowEndTime
ParameterLabels:
MasterUsername:
default: Master Username
MasterUserPassword:
default: Master User Password
CidrBlocks:
default: CIDR Blocks
CidrSize:
default: CIDR Size
AvailabilityZones:
default: Availability Zones
NumberOfAvailabilityZones:
default: Number Of Availability Zones
MultiAZ:
default: Multi AZ
PortNumber:
default: Port Number
DBInstanceClass:
default: DB Instance Class
AllocatedStorageAndIops:
default: Allocated Storage And IOPS
EngineVersion:
default: Engine Version
MysqlServerTimezone:
default: MariaDB Server Timezone
VpcId:
default: VPC Id
PubliclyAccessible:
default: Publicly Accessible
AccessCidr:
default: Access CIDR
PreferredBackupWindow:
default: Preferred Backup Window
PreferredMaintenanceWindowDay:
default: Preferred Maintenance Window Day
PreferredMaintenanceWindowStartTime:
default: Preferred MaintenanceWindow Start Time
PreferredMaintenanceWindowEndTime:
default: Preferred Maintenance Window End Time
Parameters:
AccessCidr:
Description: CIDR block to allow to connect to database
Type: String
AllocatedStorageAndIops:
Description: Storage/IOPS to allocate
Type: String
Default: 100 GB / 1,000 IOPS
AllowedValues:
- 100 GB / 1,000 IOPS
- 300 GB / 3,000 IOPS
- 600 GB / 6,000 IOPS
- 1,000 GB / 10,000 IOPS
- 1,500 GB / 15,000 IOPS
- 2,000 GB / 20,000 IOPS
- 3,000 GB / 30,000 IOPS
- 4,000 GB / 40,000 IOPS
- 6,000 GB / 60,000 IOPS
AllowMajorVersionUpgrade:
Description: If you update the EngineVersion property to a version that's different
from the DB instance's current major version, set this property to true.
Type: String
Default: 'false'
AllowedValues:
- 'true'
- 'false'
AutoMinorVersionUpgrade:
Description: Indicates that minor engine upgrades are applied automatically to
the DB instance during the maintenance window.
Type: String
Default: 'true'
AllowedValues:
- 'true'
- 'false'
AvailabilityZones:
Description: list of availability zones to use, must be the same quantity as specified
in NumberOfAvailabilityZones
Type: CommaDelimitedList
Default: Auto
BackupRetentionPeriod:
Description: The number of days during which automatic DB snapshots are retained.
Setting 0 disables automatic snapshots, maximum value is 35
Type: Number
Default: 35
MinValue: 0
MaxValue: 35
CidrBlocks:
Description: comma seperated list of CIDR blocks to place RDS into, must be the
same quantity as specified in NumberOfAvailabilityZones
Type: CommaDelimitedList
Default: Auto
CidrSize:
Description: Size of Cidr block to allocate if CidrBlocks is set to Auto.
Type: String
Default: 27
CopyTagsToSnapshot:
Description: Indicates whether to copy all of the user-defined tags from the DB
instance to snapshots of the DB instance.
Type: String
Default: 'true'
AllowedValues:
- 'true'
- 'false'
DBInstanceClass:
Description: The compute and memory capacity of the DB instance.
Type: String
Default: db.m4.xlarge
AllowedValues:
- db.m1.small
- db.m1.medium
- db.m1.large
- db.m1.xlarge
- db.m2.xlarge
- db.m2.2xlarge
- db.m2.4xlarge
- db.m3.medium
- db.m3.large
- db.m3.xlarge
- db.m3.2xlarge
- db.m4.large
- db.m4.xlarge
- db.m4.2xlarge
- db.m4.4xlarge
- db.m4.10xlarge
- db.r3.large
- db.r3.xlarge
- db.r3.2xlarge
- db.r3.4xlarge
- db.r3.8xlarge
- db.t2.micro
- db.t2.small
- db.t2.medium
- db.t2.large
DBName:
Description: The name of the database to create when the DB instance is created,
will be autogenerated if set to "Auto"
Type: String
MinLength: '1'
MaxLength: '64'
Default: Auto
AllowedPattern: ^(?!^mysql$)(?!^performance_schema$)(?!^information_schema$)[a-zA-Z0-9]*$
ConstraintDescription: must contain from 1 to 64 alphanumeric characters, and
not be reserved mariadb term.
EngineVersion:
Description: The version number of the database engine to use.
Type: String
Default: 10.1.23
AllowedValues:
- 10.0.17
- 10.0.24
- 10.0.28
- 10.0.31
- 10.1.14
- 10.1.19
- 10.1.23
MasterUserPassword:
Description: Master user database Password, if left at default a 32 character
password will be generated
Type: String
Default: Auto
NoEcho: 'True'
MasterUsername:
Description: Master database Username
Type: String
MonitoringInterval:
Description: The interval, in seconds, between points when Enhanced Monitoring
metrics are collected for the DB instance.
Type: String
Default: '1'
AllowedValues:
- '0'
- '1'
- '5'
- '10'
- '15'
- '30'
- '60'
MultiAZ:
Description: Specifies if the database instance is a multiple Availability Zone
deployment.
Type: String
Default: 'true'
AllowedValues:
- 'true'
- 'false'
MysqlServerTimezone:
Description: The default timezone for the database engine to use.
Type: String
Default: UTC
AllowedValues:
- Africa/Cairo
- Africa/Casablanca
- Africa/Harare
- Africa/Monrovia
- Africa/Nairobi
- Africa/Tripoli
- Africa/Windhoek
- America/Araguaina
- America/Asuncion
- America/Bogota
- America/Caracas
- America/Chihuahua
- America/Cuiaba
- America/Denver
- America/Fortaleza
- America/Guatemala
- America/Halifax
- America/Manaus
- America/Matamoros
- America/Monterrey
- America/Montevideo
- America/Phoenix
- America/Santiago
- America/Tijuana
- Asia/Amman
- Asia/Ashgabat
- Asia/Baghdad
- Asia/Baku
- Asia/Bangkok
- Asia/Beirut
- Asia/Calcutta
- Asia/Damascus
- Asia/Dhaka
- Asia/Irkutsk
- Asia/Jerusalem
- Asia/Kabul
- Asia/Karachi
- Asia/Kathmandu
- Asia/Krasnoyarsk
- Asia/Magadan
- Asia/Muscat
- Asia/Novosibirsk
- Asia/Riyadh
- Asia/Seoul
- Asia/Shanghai
- Asia/Singapore
- Asia/Taipei
- Asia/Tehran
- Asia/Tokyo
- Asia/Ulaanbaatar
- Asia/Vladivostok
- Asia/Yakutsk
- Asia/Yerevan
- Atlantic/Azores
- Australia/Adelaide
- Australia/Brisbane
- Australia/Darwin
- Australia/Hobart
- Australia/Perth
- Australia/Sydney
- Canada/Newfoundland
- Canada/Saskatchewan
- Brazil/East
- Europe/Amsterdam
- Europe/Athens
- Europe/Dublin
- Europe/Helsinki
- Europe/Istanbul
- Europe/Kaliningrad
- Europe/Moscow
- Europe/Paris
- Europe/Prague
- Europe/Sarajevo
- Pacific/Auckland
- Pacific/Fiji
- Pacific/Guam
- Pacific/Honolulu
- Pacific/Samoa
- US/Alaska
- US/Central
- US/Eastern
- US/East-Indiana
- US/Pacific
- UTC
NumberOfAvailabilityZones:
Description: Quantity of subnets to use, if selecting more than 2 the region this
stack is in must have at least that many Availability Zones
Type: String
Default: '2'
AllowedValues:
- '2'
- '3'
- '4'
- '5'
PortNumber:
Description: The port number for the database server to listen on
Type: Number
Default: 10001
MinValue: 1150
MaxValue: 65535
PreferredBackupWindow:
Description: The daily time range in UTC during which automated backups are created
(if automated backups are enabled). Cannot overlap with PreferredMaintenanceWindowTime
Type: String
Default: 00:00-02:00
AllowedValues:
- 00:00-02:00
- 01:00-03:00
- 02:00-04:00
- 03:00-05:00
- 04:00-06:00
- 05:00-07:00
- 06:00-08:00
- 07:00-09:00
- 08:00-10:00
- 09:00-11:00
- 10:00-12:00
- 11:00-13:00
- 12:00-14:00
- 13:00-15:00
- 14:00-16:00
- 15:00-17:00
- 16:00-18:00
- 17:00-19:00
- 18:00-20:00
- 19:00-21:00
- 20:00-22:00
- 21:00-23:00
- 22:00-24:00
PreferredMaintenanceWindowDay:
Description: The day of the week which RDS maintenance will be performed
Type: String
Default: Mon
AllowedValues:
- Mon
- Tue
- Wed
- Thu
- Fri
- Sat
- Sun
PreferredMaintenanceWindowEndTime:
Description: The weekly end time in UTC for the RDS maintenance window, must be
more than PreferredMaintenanceWindowEndTime and cannot overlap with PreferredBackupWindow
Type: String
Default: 06:00
AllowedValues:
- 00:00
- 01:00
- 02:00
- 03:00
- 04:00
- 05:00
- 06:00
- 07:00
- 08:00
- 09:00
- '10:00'
- '11:00'
- '12:00'
- '13:00'
- '14:00'
- '15:00'
- '16:00'
- '17:00'
- '18:00'
- '19:00'
- '20:00'
- '21:00'
- '22:00'
PreferredMaintenanceWindowStartTime:
Description: The weekly start time in UTC for the RDS maintenance window, must
be less than PreferredMaintenanceWindowEndTime and cannot overlap with PreferredBackupWindow
Type: String
Default: 04:00
AllowedValues:
- 00:00
- 01:00
- 02:00
- 03:00
- 04:00
- 05:00
- 06:00
- 07:00
- 08:00
- 09:00
- '10:00'
- '11:00'
- '12:00'
- '13:00'
- '14:00'
- '15:00'
- '16:00'
- '17:00'
- '18:00'
- '19:00'
- '20:00'
- '21:00'
- '22:00'
PubliclyAccessible:
Description: Indicates whether the DB instance is an Internet-facing instance.
Type: String
Default: 'false'
AllowedValues:
- 'true'
- 'false'
StorageEncrypted:
Description: Indicates whether the DB instance is encrypted.
Type: String
Default: 'true'
AllowedValues:
- 'true'
- 'false'
StorageType:
Description: Specifies the storage type to be associated with the DB instance.
Type: String
Default: io1
AllowedValues:
- io1
- gp2
- standard
VpcId:
Description: The ID of the VPC to launch the RDS instance into
Type: AWS::EC2::VPC::Id
Mappings:
Version2Family:
10.0.17:
Family: mariadb10.0
MajorVersion: '10.0'
10.0.24:
Family: mariadb10.0
MajorVersion: '10.0'
10.0.28:
Family: mariadb10.0
MajorVersion: '10.0'
10.0.31:
Family: mariadb10.0
MajorVersion: '10.0'
10.1.14:
Family: mariadb10.1
MajorVersion: '10.1'
10.1.19:
Family: mariadb10.1
MajorVersion: '10.1'
10.1.23:
Family: mariadb10.1
MajorVersion: '10.1'
Conditions:
3az:
!Or
- !Equals
- !Ref NumberOfAvailabilityZones
- '3'
- !Equals
- !Ref NumberOfAvailabilityZones
- '4'
- !Equals
- !Ref NumberOfAvailabilityZones
- '5'
4az:
!Or
- !Equals
- !Ref NumberOfAvailabilityZones
- '4'
- !Equals
- !Ref NumberOfAvailabilityZones
- '5'
5az:
!Equals
- !Ref NumberOfAvailabilityZones
- '5'
100GB:
!Equals
- !Ref AllocatedStorageAndIops
- 100 GB / 1,000 IOPS
300GB:
!Equals
- !Ref AllocatedStorageAndIops
- 300 GB / 3,000 IOPS
600GB:
!Equals
- !Ref AllocatedStorageAndIops
- 600 GB / 6,000 IOPS
1000GB:
!Equals
- !Ref AllocatedStorageAndIops
- 1,000 GB / 10,000 IOPS
1500GB:
!Equals
- !Ref AllocatedStorageAndIops
- 1,500 GB / 15,000 IOPS
2000GB:
!Equals
- !Ref AllocatedStorageAndIops
- 2,000 GB / 20,000 IOPS
3000GB:
!Equals
- !Ref AllocatedStorageAndIops
- 3,000 GB / 30,000 IOPS
4000GB:
!Equals
- !Ref AllocatedStorageAndIops
- 4,000 GB / 40,000 IOPS
AuditSupported:
!Not
- !Equals
- !Ref EngineVersion
- 10.0.17
AutoCidrs:
!Equals
- !Select
- 0
- !Ref CidrBlocks
- Auto
AutoAzs:
!Equals
- !Select
- 0
- !Ref AvailabilityZones
- Auto
AutoPassword:
!Equals
- !Ref MasterUserPassword
- Auto
AutoDBName:
!Equals
- !Ref DBName
- Auto
Resources:
DBInstance:
Type: AWS::RDS::DBInstance
DeletionPolicy: Snapshot
Properties:
AllocatedStorage:
!If
- 100GB
- '100'
- !If
- 300GB
- '300'
- !If
- 600GB
- '600'
- !If
- 1000GB
- '1000'
- !If
- 1500GB
- '1500'
- !If
- 2000GB
- '2000'
- !If
- 3000GB
- '3000'
- !If
- 4000GB
- '4000'
- '6000'
AllowMajorVersionUpgrade: !Ref AllowMajorVersionUpgrade
AutoMinorVersionUpgrade: !Ref AutoMinorVersionUpgrade
BackupRetentionPeriod: !Ref BackupRetentionPeriod
CopyTagsToSnapshot: !Ref CopyTagsToSnapshot
DBInstanceClass: !Ref DBInstanceClass
DBName:
!If
- AutoDBName
- !GetAtt AWSSBInjectedGenerateDBName.DBName
- !Ref DBName
DBParameterGroupName: !Ref DBParameterGroup
DBSubnetGroupName: !Ref DBSubnetGroup
Engine: mariadb
EngineVersion: !Ref EngineVersion
Iops:
!If
- 100GB
- '1000'
- !If
- 300GB
- '3000'
- !If
- 600GB
- '6000'
- !If
- 1000GB
- '10000'
- !If
- 1500GB
- '15000'
- !If
- 2000GB
- '20000'
- !If
- 3000GB
- '30000'
- !If
- 4000GB
- '40000'
- '60000'
KmsKeyId: !GetAtt KMSKey.Arn
LicenseModel: general-public-license
MasterUsername: !Ref MasterUsername
MasterUserPassword:
!If
- AutoPassword
- !GetAtt AWSSBInjectedGeneratePassword.MasterUserPassword
- !Ref MasterUserPassword
MonitoringInterval: !Ref MonitoringInterval
MonitoringRoleArn: !GetAtt MonitoringRole.Arn
MultiAZ: !Ref MultiAZ
OptionGroupName: !Ref DBOptionGroup
Port: !Ref PortNumber
PreferredBackupWindow: !Ref PreferredBackupWindow
PreferredMaintenanceWindow: !Sub ${PreferredMaintenanceWindowDay}:${PreferredMaintenanceWindowStartTime}-${PreferredMaintenanceWindowDay}:${PreferredMaintenanceWindowEndTime}
PubliclyAccessible: !Ref PubliclyAccessible
StorageEncrypted: !Ref StorageEncrypted
StorageType: !Ref StorageType
VPCSecurityGroups:
- !Ref RDSSecurityGroup
DBOptionGroup:
Type: AWS::RDS::OptionGroup
DeletionPolicy: Retain
Properties:
EngineName: mariadb
MajorEngineVersion:
!FindInMap
- Version2Family
- !Ref EngineVersion
- MajorVersion
OptionGroupDescription: !Sub StackName ${AWS::StackName} Database ${DBName}
OptionConfigurations:
- !If
- AuditSupported
- OptionName: MARIADB_AUDIT_PLUGIN
OptionSettings:
- Name: SERVER_AUDIT_FILE_ROTATE_SIZE
Value: '100000000'
- Name: SERVER_AUDIT_FILE_ROTATIONS
Value: '100'
- !Ref AWS::NoValue
DBParameterGroup:
Type: AWS::RDS::DBParameterGroup
Properties:
Description: !Sub StackName ${AWS::StackName} Database ${DBName}
Family:
!FindInMap
- Version2Family
- !Ref EngineVersion
- Family
Parameters:
time_zone: !Ref MysqlServerTimezone
DBSubnet1:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
!Select
- 0
- !If
- AutoAzs
- !GetAtt AWSSBInjectedGetAzs.AvailabilityZones
- !Ref AvailabilityZones
VpcId: !Ref VpcId
CidrBlock:
!Select
- 0
- !If
- AutoCidrs
- !GetAtt AWSSBInjectedGetCidrs.CidrBlocks
- !Ref CidrBlocks
DBSubnet2:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
!Select
- 1
- !If
- AutoAzs
- !GetAtt AWSSBInjectedGetAzs.AvailabilityZones
- !Ref AvailabilityZones
VpcId: !Ref VpcId
CidrBlock:
!Select
- 1
- !If
- AutoCidrs
- !GetAtt AWSSBInjectedGetCidrs.CidrBlocks
- !Ref CidrBlocks
DBSubnet3:
Condition: 3az
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
!Select
- 2
- !If
- AutoAzs
- !GetAtt AWSSBInjectedGetAzs.AvailabilityZones
- !Ref AvailabilityZones
VpcId: !Ref VpcId
CidrBlock:
!Select
- 2
- !If
- AutoCidrs
- !GetAtt AWSSBInjectedGetCidrs.CidrBlocks
- !Ref CidrBlocks
DBSubnet4:
Condition: 4az
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
!Select
- 3
- !If
- AutoAzs
- !GetAtt AWSSBInjectedGetAzs.AvailabilityZones
- !Ref AvailabilityZones
VpcId: !Ref VpcId
CidrBlock:
!Select
- 3
- !If
- AutoCidrs
- !GetAtt AWSSBInjectedGetCidrs.CidrBlocks
- !Ref CidrBlocks
DBSubnet5:
Condition: 5az
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
!Select
- 4
- !If
- AutoAzs
- !GetAtt AWSSBInjectedGetAzs.AvailabilityZones
- !Ref AvailabilityZones
VpcId: !Ref VpcId
CidrBlock:
!Select
- 4
- !If
- AutoCidrs
- !GetAtt AWSSBInjectedGetCidrs.CidrBlocks
- !Ref CidrBlocks
DBSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: !Sub StackName ${AWS::StackName} Database ${DBName}
SubnetIds:
- !Ref DBSubnet1
- !Ref DBSubnet2
- !If
- 3az
- !Ref DBSubnet3
- !Ref AWS::NoValue
- !If
- 4az
- !Ref DBSubnet4
- !Ref AWS::NoValue
- !If
- 5az
- !Ref DBSubnet5
- !Ref AWS::NoValue
KMSKey:
Type: AWS::KMS::Key
Properties:
Description: !Sub StackName ${AWS::StackName} Database ${DBName}
Enabled: 'true'
EnableKeyRotation: 'true'
KeyPolicy:
Version: '2012-10-17'
Id: key-default-1
Statement:
- Sid: Allow administration of the key
Effect: Allow
Principal:
AWS: !Sub arn:aws:iam::${AWS::AccountId}:root
Action:
- kms:Create*
- kms:Describe*
- kms:Enable*
- kms:List*
- kms:Put*
- kms:Update*
- kms:Revoke*
- kms:Disable*
- kms:Get*
- kms:Delete*
- kms:ScheduleKeyDeletion
- kms:CancelKeyDeletion
Resource: '*'
MonitoringRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: monitoring.rds.amazonaws.com
Action: sts:AssumeRole
Path: /
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole
RDSSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: '!Sub Allow Client connections to StackName ${AWS::StackName}
Database ${DBName}'
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: !Ref PortNumber
ToPort: !Ref PortNumber
CidrIp: !Ref AccessCidr
SecurityGroupEgress:
- IpProtocol: '-1'
FromPort: '-1'
ToPort: '-1'
CidrIp: 0.0.0.0/0
AWSSBInjectedLambdaZipsBucket:
Type: AWS::S3::Bucket
Properties:
Tags: []
AWSSBInjectedCopyZips:
Type: AWS::CloudFormation::CustomResource
Properties:
ServiceToken: !GetAtt AWSSBInjectedCopyZipsLambda.Arn
DestBucket: !Ref AWSSBInjectedLambdaZipsBucket
SourceBucket: awsservicebrokeralpha
Prefix: functions/
Objects:
- get_cidrs/lambda_function.zip
- get_azs/lambda_function.zip
- generate_password/lambda_function.zip
- generate_dbname/lambda_function.zip
AWSSBInjectedCopyZipsRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Path: /
Policies:
- PolicyName: lambda-copier
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- s3:GetObject
Resource:
- arn:aws:s3:::awsservicebrokeralpha/*
- Effect: Allow
Action:
- s3:PutObject
- s3:DeleteObject
Resource:
- !Sub arn:aws:s3:::${AWSSBInjectedLambdaZipsBucket}/*
AWSSBInjectedCopyZipsLambda:
Type: AWS::Lambda::Function
Properties:
Description: Copies objects from a source S3 bucket to a destination
Handler: index.handler
Runtime: python2.7
Role: !GetAtt AWSSBInjectedCopyZipsRole.Arn
Timeout: 240
Code:
ZipFile: |
import json
import logging
import threading
import boto3
import cfnresponse
def copy_objects(source_bucket, dest_bucket, prefix, objects):
s3 = boto3.client('s3')
for o in objects:
key = prefix + o
copy_source = {
'Bucket': source_bucket,
'Key': key
}
print('copy_source: %s' % copy_source)
print('dest_bucket = %s' % dest_bucket)
print('key = %s' % key)
s3.copy_object(CopySource=copy_source, Bucket=dest_bucket, Key=key)