This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
/
aws-refarch-drupal-03-rds.yaml
168 lines (158 loc) · 4.93 KB
/
aws-refarch-drupal-03-rds.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
---
AWSTemplateFormatVersion: 2010-09-09
Description: Reference Architecture to host Drupal on AWS - Creates RDS Aurora database cluster
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Database Parameters
Parameters:
- DatabaseInstanceType
- DatabaseMasterUsername
- DatabaseMasterPassword
- DatabaseName
- DatabaseSecurityGroup
- DataSubnet0
- DataSubnet1
- DataSubnet2
ParameterLabels:
DatabaseInstanceType:
default: DB Instance Class
DatabaseMasterUsername:
default: DB Master Username
DatabaseMasterPassword:
default: DB Master Password
DatabaseName:
default: DB Name
DatabaseSecurityGroup:
default: DB Security Group
DataSubnet0:
default: Data Subnet for AZ 0
DataSubnet1:
default: Data Subnet for AZ 1
DataSubnet2:
default: Data Subnet for AZ 2
Parameters:
DatabaseInstanceType:
AllowedValues:
- db.t2.small
- db.t2.medium
- db.r3.large
- db.r3.xlarge
- db.r3.2xlarge
- db.r3.4xlarge
- db.r3.8xlarge
ConstraintDescription: Must be a valid RDS instance class.
Default: db.t2.medium
Description: The Amazon RDS database instance class.
Type: String
DatabaseMasterUsername:
AllowedPattern: ^([a-zA-Z0-9]*)$
Description: The Amazon RDS master username.
ConstraintDescription: Must contain only alphanumeric characters and be at least 8 characters.
MaxLength: 16
MinLength: 1
Type: String
DatabaseMasterPassword:
AllowedPattern: ^([a-z0-9A-Z`~!#$%^&*()_+,\\-])*$
ConstraintDescription: Must be letters (upper or lower), numbers, and these special characters '_'`~!#$%^&*()_+,-
Description: The Amazon RDS master password.
MaxLength: 41
MinLength: 8
NoEcho: true
Type: String
DatabaseName:
AllowedPattern: ^([a-zA-Z0-9]*)$
Description: The Amazon RDS master database name.
Type: String
DatabaseSecurityGroup:
Description: Select the database security group.
Type: AWS::EC2::SecurityGroup::Id
DataSubnet0:
Description: Select an existing database subnet for AZ 0.
Type: AWS::EC2::Subnet::Id
DataSubnet1:
Description: Select an existing database subnet for AZ 1.
Type: AWS::EC2::Subnet::Id
DataSubnet2:
Description: Select an existing database subnet for AZ 2.
Type: AWS::EC2::Subnet::Id
Conditions:
MoreThan2AZ:
!Or [
!Equals [ !Ref 'AWS::Region', us-east-1 ],
!Equals [ !Ref 'AWS::Region', us-east-2 ],
!Equals [ !Ref 'AWS::Region', us-west-2 ],
!Equals [ !Ref 'AWS::Region', eu-west-1 ],
!Equals [ !Ref 'AWS::Region', sa-east-1 ],
!Equals [ !Ref 'AWS::Region', ap-northeast-1 ],
!Equals [ !Ref 'AWS::Region', ap-southeast-2 ]
]
Resources:
DatabaseCluster:
Type: AWS::RDS::DBCluster
Properties:
BackupRetentionPeriod: 30
DatabaseName: !Ref DatabaseName
DBSubnetGroupName: !Ref DataSubnetGroup
Engine: aurora
MasterUsername: !Ref DatabaseMasterUsername
MasterUserPassword: !Ref DatabaseMasterPassword
Port: 3306
Tags:
- Key: Name
Value: !Join [ '', [ 'Drupal / ', !Ref 'AWS::StackName' ] ]
VpcSecurityGroupIds:
- !Ref DatabaseSecurityGroup
DatabaseInstance0:
Type: AWS::RDS::DBInstance
DeletionPolicy: Delete
Properties:
AllowMajorVersionUpgrade: false
AutoMinorVersionUpgrade: true
DBClusterIdentifier: !Ref DatabaseCluster
DBInstanceClass: !Ref DatabaseInstanceType
DBSubnetGroupName: !Ref DataSubnetGroup
Engine: aurora
Tags:
- Key: Name
Value: !Join [ '', [ 'Drupal / ', !Ref 'AWS::StackName' ] ]
DatabaseInstance1:
Type: AWS::RDS::DBInstance
DeletionPolicy: Delete
Properties:
AllowMajorVersionUpgrade: false
AutoMinorVersionUpgrade: true
DBClusterIdentifier: !Ref DatabaseCluster
DBInstanceClass: !Ref DatabaseInstanceType
DBSubnetGroupName: !Ref DataSubnetGroup
Engine: aurora
Tags:
- Key: Name
Value: !Join [ '', [ 'Drupal / ', !Ref 'AWS::StackName' ] ]
DataSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: RDS Database Subnet Group for Drupal
SubnetIds:
!If [
MoreThan2AZ,
[ !Ref DataSubnet0, !Ref DataSubnet1, !Ref DataSubnet2 ],
[ !Ref DataSubnet0, !Ref DataSubnet1 ]
]
Tags:
- Key: Name
Value: !Join [ '', [ 'Drupal / ', !Ref 'AWS::StackName' ] ]
Outputs:
DatabaseCluster:
Value: !Ref DatabaseCluster
DatabaseName:
Value: !Ref DatabaseName
DatabaseInstance0:
Value: !Ref DatabaseInstance0
DatabaseInstance1:
Value: !Ref DatabaseInstance1
DataSubnetGroup:
Value: !Ref DataSubnetGroup
DatabaseClusterEndpointAddress:
Value: !GetAtt DatabaseCluster.Endpoint.Address