-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRDS MySql.yml
307 lines (304 loc) · 7.56 KB
/
RDS MySql.yml
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
# Create an RDS MySql 5.7 Instance
Parameters:
Owner:
Description: Enter the Name of the owner for this Stack.
Type: String
Default: Name
VPC:
Description: Select VPC form the available VPCs in your account.
Type: AWS::EC2::VPC::Id
PrivateSubnet1:
Description: Select Private Subnet 1.
Type: AWS::EC2::Subnet::Id
PrivateSubnet2:
Description: Select Private Subnet 2.
Type: AWS::EC2::Subnet::Id
MasterUsername:
Description: Database administration name.
Type: String
Default: rdsroot
MasterUserPassword:
NoEcho: 'true'
Description: Database administration password.
Type: String
MinLength: '8'
AllowedPattern: "[a-zA-Z0-9!?]*"
ConstraintDescription: Must only contain upper and lowercase letters and numbers
BackupRetentionPeriod:
Description: Enter Backup Retention Period in Days.
Type: Number
Default: '5'
MultiAvailabilityZone:
Description: Do you want to Enable Multi Availability Zones?
Type: String
Default: 'true'
AllowedValues:
- 'true'
- 'false'
TcpPort:
Description: Enter RDS Listening TCP Port number.
Type: Number
Default: '3306'
PreferredBackupWindow:
Description: Enter Preferred Backup Window Time.
Type: String
Default: 15:00-17:00
PreferredMaintenanceWindow:
Description: Enter Preferred Maintenance Window Time.
Type: String
Default: Sun:18:00-Sun:22:00
AllocatedStorage:
Default: '15'
Description: Enter the size of the database (Gb)
Type: Number
MinValue: '5'
MaxValue: '6144'
ConstraintDescription: Must be between 5-6144
SnapshotOnDelete:
Description: Do you want to create a Snapshot on instance delete?
Type: String
Default: 'true'
AllowedValues:
- 'true'
- 'false'
AutoMinorVersionUpgrade:
Description: Do you want to allow automatic minor version upgrade?
Type: String
Default: 'true'
AllowedValues:
- 'true'
- 'false'
InstanceType:
Description: Select Instance Type.
Type: String
Default: db.t2.micro
ConstraintDescription: Must be a valid EC2 instance type.
Mappings:
Settings:
MySQL:
Engine: MySQL
Version: '5.7'
Conditions:
ConfigureSnapshotOnDelete:
Fn::Equals:
- Ref: SnapshotOnDelete
- 'true'
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Ownership
Parameters:
- Owner
- Label:
default: Network Configuration
Parameters:
- VPC
- PrivateSubnet1
- PrivateSubnet2
- Label:
default: RDS Configuration
Parameters:
- InstanceType
- MasterUsername
- MasterUserPassword
- BackupRetentionPeriod
- PreferredBackupWindow
- PreferredMaintenanceWindow
- SnapshotOnDelete
- AllocatedStorage
- AutoMinorVersionUpgrade
- TcpPort
- MultiAvailabilityZone
ParameterLabels:
Owner:
default: Team or Individual Owner
InstanceType:
default: Instance Type
PrivateSubnet1:
default: Private Subnet 1
PrivateSubnet2:
default: Private Subnet 2
MasterUsername:
default: Master Username
MasterUserPassword:
default: Master User Password
BackupRetentionPeriod:
default: Backup Retention Period
PreferredBackupWindow:
default: Preferred Backup Window
PreferredMaintenanceWindow:
default: Preferred Maintenance Window
AllocatedStorage:
default: Allocated Storage
AutoMinorVersionUpgrade:
default: Auto Minor Version Upgrade
TcpPort:
default: TCP Port
MultiAvailabilityZone:
default: Multi Availability Zone?
SnapshotOnDelete:
default: Snapshot On Delete?
Resources:
RDSAccessSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Instance to RDS Access
VpcId:
Ref: VPC
Tags:
- Key: Name
Value:
Fn::Join:
- ''
- - Ref: AWS::StackName
- "-rds"
- Key: Owner
Value:
Ref: Owner
AccessSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
DependsOn: RDSAccessSecurityGroup
Properties:
GroupId:
Ref: RDSAccessSecurityGroup
IpProtocol: tcp
FromPort:
Ref: TcpPort
ToPort:
Ref: TcpPort
SourceSecurityGroupId:
Ref: RDSAccessSecurityGroup
DbSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription:
Fn::Join:
- ''
- - 'RDS Subnet Group for '
- Ref: AWS::StackName
SubnetIds:
- Ref: PrivateSubnet1
- Ref: PrivateSubnet2
Tags:
- Key: Name
Value:
Ref: AWS::StackName
- Key: Owner
Value:
Ref: Owner
DbInstance:
Type: AWS::RDS::DBInstance
DeletionPolicy: Snapshot
DependsOn:
- DbSubnetGroup
- RDSAccessSecurityGroup
Properties:
AllocatedStorage:
Ref: AllocatedStorage
AllowMajorVersionUpgrade: 'false'
AutoMinorVersionUpgrade:
Ref: AutoMinorVersionUpgrade
BackupRetentionPeriod:
Ref: BackupRetentionPeriod
DBInstanceClass:
Ref: InstanceType
DBInstanceIdentifier:
Ref: AWS::StackName
DBSubnetGroupName:
Ref: DbSubnetGroup
Engine:
Fn::FindInMap:
- Settings
- MySQL
- Engine
EngineVersion:
Fn::FindInMap:
- Settings
- MySQL
- Version
MasterUsername:
Ref: MasterUsername
MasterUserPassword:
Ref: MasterUserPassword
MultiAZ:
Ref: MultiAvailabilityZone
Port:
Ref: TcpPort
PreferredBackupWindow:
Ref: PreferredBackupWindow
PreferredMaintenanceWindow:
Ref: PreferredMaintenanceWindow
PubliclyAccessible: 'false'
StorageEncrypted: 'false'
StorageType: gp2
VPCSecurityGroups:
- Ref: RDSAccessSecurityGroup
Tags:
- Key: Name
Value:
Ref: AWS::StackName
- Key: Owner
Value:
Ref: Owner
Outputs:
Owner:
Description: Team or Individual that Owns this Formation.
Value:
Ref: Owner
VPC:
Description: VPC Used
Value:
Ref: VPC
RDSHostname:
Description: RDS Hostname
Value:
Fn::GetAtt:
- DbInstance
- Endpoint.Address
RDSPort:
Description: RDS Port
Value:
Fn::GetAtt:
- DbInstance
- Endpoint.Port
DbSubnetGroup:
Description: DB Subnet Group Created.
Value:
Ref: DbSubnetGroup
RDSAccessSecurityGroup:
Description: RDS Access Security Group Created.
Value:
Ref: RDSAccessSecurityGroup
PrivateSubnet1:
Description: Private Subnet 1 Deployment
Value:
Ref: PrivateSubnet1
PrivateSubnet2:
Description: Private Subnet 2 Deployment
Value:
Ref: PrivateSubnet2
BackupRetentionPeriod:
Description: Backup Retention Period in Days
Value:
Ref: BackupRetentionPeriod
MultiAvailabilityZone:
Description: Enable Multi Availability Zones?
Value:
Ref: MultiAvailabilityZone
SnapshotOnDelete:
Description: Create Snapshot on Delete?
Value:
Ref: SnapshotOnDelete
PreferredBackupWindow:
Description: Preferred Backup Window
Value:
Ref: PreferredBackupWindow
PreferredMaintenanceWindow:
Description: Preferred Maintenance Window
Value:
Ref: PreferredMaintenanceWindow
AllocatedStorage:
Description: Allocated Storage in GB
Value:
Ref: AllocatedStorage