-
Notifications
You must be signed in to change notification settings - Fork 0
/
rds.yaml
134 lines (121 loc) · 3.79 KB
/
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
AWSTemplateFormatVersion: "2010-09-09"
Description: This stack creates MySQL DB instance
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: Export VPC Stack Name
Parameters:
- ExportVpcStackName
-
Label:
default: Database Parameters
Parameters:
- DatabaseInstanceIdentifier
- DatabaseName
- DatabaseUser
- DatabasePassword
- DatabaseBackupRetentionPeriod
- DatabaseAllocatedStorage
- DatabaseInstanceClass
- MultiAZDatabase
Parameters:
ExportVpcStackName:
Description: The name of the vpc stack that exports values
Type: String
DatabaseInstanceIdentifier:
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: Must begin with a letter and contain only alphanumeric characters
Default: mysql57db
Description: Instance identifier name
MaxLength: 60
MinLength: 1
Type: String
DatabaseName:
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: Must begin with a letter and contain only alphanumeric characters
Default: applicationdb
Description: MySQL DB Name
MaxLength: 64
MinLength: 1
Type: String
DatabaseUser:
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: Must begin with a letter and contain only alphanumeric characters
Default: dbadmin
Description: Username for MySQL database access
MaxLength: 16
MinLength: 1
NoEcho: true
Type: String
DatabasePassword:
AllowedPattern: '[a-zA-Z0-9]*'
ConstraintDescription: Must contain only alphanumeric characters
Default: database1407
Description: Password for MySQL database access
MaxLength: 41
MinLength: 8
NoEcho: true
Type: String
DatabaseBackupRetentionPeriod:
ConstraintDescription: Database backup retention period must be between 0 and 35 days
Default: 0
Description: The number of days for which automatic DB snapshots are retained
MaxValue: 35
MinValue: 0
Type: Number
DatabaseAllocatedStorage:
ConstraintDescription: Must be between 5 and 1024Gb
Default: 20
Description: The size of the database (Gb)
MaxValue: 65536
MinValue: 5
Type: Number
DatabaseInstanceClass:
AllowedValues:
- db.t1.micro
- db.t2.micro
- db.m1.small
- db.m1.medium
- db.m1.large
ConstraintDescription: Must select a valid DB instance type
Default: db.t2.micro
Description: The DB instance type
Type: String
MultiAZDatabase:
AllowedValues:
- true
- false
ConstraintDescription: Must be either true or false
Default: false
Description: Create a Multi-AZ MySQL RDS DB
Type: String
Resources:
DatabaseSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: Subnet group DB
SubnetIds:
- Fn::ImportValue: !Sub ${ExportVpcStackName}-PrivateSubnet3
- Fn::ImportValue: !Sub ${ExportVpcStackName}-PrivateSubnet4
Tags:
- Key: Name
Value: Subnet group for DB Instance
DatabaseInstance:
Type: AWS::RDS::DBInstance
Properties:
AllocatedStorage: !Ref DatabaseAllocatedStorage
AvailabilityZone: !Select [ 0, !GetAZs '' ]
BackupRetentionPeriod: !Ref DatabaseBackupRetentionPeriod
DBInstanceClass: !Ref DatabaseInstanceClass
DBInstanceIdentifier: !Ref DatabaseInstanceIdentifier
DBName: !Ref DatabaseName
DBSubnetGroupName: !Ref DatabaseSubnetGroup
Engine: MySQL
EngineVersion: 5.7.31
MasterUsername: !Ref DatabaseUser
MasterUserPassword: !Ref DatabasePassword
MultiAZ: !Ref MultiAZDatabase
VPCSecurityGroups:
Fn::ImportValue: !Sub ${ExportVpcStackName}-DataBaseSecurityGroup