-
Notifications
You must be signed in to change notification settings - Fork 35
/
db-instance.yml
208 lines (208 loc) · 4.62 KB
/
db-instance.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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建RDS实例、账户、权限及读副本,配置参数与安全组,支持MySQL/SQLServer/PostgreSQL。
en: Create RDS instances, accounts, permissions, and read replicas; configure parameters
and security groups; supporting MySQL, SQL Server, and PostgreSQL.
Parameters:
EngineVersion:
Type: String
Description: 'MySQL: 5.5、5.6、5.7、5.8,SQLServer:2008r2,PostgreSQL:9.4'
DBInstanceClass:
Type: String
Description: Instance Class
Default: rds.mysql.s2.large
DBInstanceStorage:
Type: Number
Description: MySQL:5-1000,SQLServer:10-1000,others:5-2000
Engine:
Type: String
Description: 'RDS Engine, Allowed values: MySQL、SQLServer、PostgreSQL、PPAS。'
DBName:
Type: String
Default: mytest
AccountType:
Type: String
Default: Normal
AllowedValues:
- Normal
- Super
AccountName:
Type: String
Default: mytest
AccountPassword:
Type: String
NoEcho: true
CharacterSetName:
Type: String
Description: 'MySQL: utf8、gbk、latin1、 utf8mb4'
Default: utf8
AccountPrivilege:
Type: String
Description: Account Privilege.
Default: ReadOnly
AllowedValues:
- ReadWrite
- ReadOnly
- DDLOnly
- DMLOnly
- DBOwner
VSwitchName:
Type: String
Default: mytest
ZoneId:
Type: String
VpcName:
Type: String
Default: mytest
DataBaseName:
Type: String
Default: mytestdb
Resources:
VPC:
Type: ALIYUN::ECS::VPC
Properties:
VpcName:
Ref: VpcName
CidrBlock: 192.168.0.0/16
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: VPC
VSwitchName:
Ref: VSwitchName
CidrBlock: 192.168.10.0/24
DependsOn: VPC
RDSInstance:
Type: ALIYUN::RDS::DBInstance
Properties:
VpcId:
Ref: VPC
VSwitchId:
Ref: VSwitch
EngineVersion:
Ref: EngineVersion
DBInstanceClass:
Ref: DBInstanceClass
SecurityIPList: 0.0.0.0/0
DBInstanceStorage:
Ref: DBInstanceStorage
Engine:
Ref: Engine
DBMappings:
- CharacterSetName:
Ref: CharacterSetName
DBName:
Ref: DBName
DependsOn: VSwitch
RDSAccount:
Type: ALIYUN::RDS::Account
Properties:
DBInstanceId:
Ref: RDSInstance
AccountType:
Ref: AccountType
AccountName:
Ref: AccountName
AccountPassword:
Ref: AccountPassword
DependsOn: RDSInstance
AccountRdsPrivilege:
Type: ALIYUN::RDS::AccountPrivilege
Properties:
AccountPrivilege:
Ref: AccountPrivilege
DBInstanceId:
Ref: RDSInstance
DBName:
Ref: DBName
AccountName:
Fn::GetAtt:
- RDSAccount
- AccountName
DependsOn: RDSAccount
DBInstanceParameterGroup:
Type: ALIYUN::RDS::DBInstanceParameterGroup
Properties:
Forcerestart: 'false'
DBInstanceId:
Ref: RDSInstance
Parameters:
- Key: back_log
Value: '3000'
- Key: wait_timeout
Value: '86400'
DependsOn: RDSInstance
DBInstanceSecurityIps:
Type: ALIYUN::RDS::DBInstanceSecurityIps
Properties:
DBInstanceId:
Ref: RDSInstance
DBInstanceIPArrayAttribute: 0.0.0.0/0
DependsOn: DBInstanceParameterGroup
ReadOnlyDBInstance:
Type: ALIYUN::RDS::ReadOnlyDBInstance
Properties:
ZoneId:
Ref: ZoneId
VPCId:
Ref: VPC
VSwitchId:
Ref: VSwitch
DBInstanceId:
Ref: RDSInstance
DBInstanceStorage:
Ref: DBInstanceStorage
EngineVersion:
Ref: EngineVersion
DBInstanceClass:
Ref: DBInstanceClass
DependsOn: RDSInstance
Database:
Type: ALIYUN::RDS::Database
Properties:
CharacterSetName: utf8mb4
DBInstanceId:
Ref: RDSInstance
DBDescription: db
DBName:
Ref: DataBaseName
DependsOn: RDSInstance
Outputs:
DBName:
Value:
Fn::GetAtt:
- Database
- DBName
SecurityIps:
Value:
Fn::GetAtt:
- DBInstanceSecurityIps
- SecurityIps
DBInstanceId:
Value:
Fn::GetAtt:
- RDSInstance
- DBInstanceId
InnerPort:
Value:
Fn::GetAtt:
- RDSInstance
- InnerPort
InnerIPAddress:
Value:
Fn::GetAtt:
- RDSInstance
- InnerIPAddress
InnerConnectionString:
Value:
Fn::GetAtt:
- RDSInstance
- InnerConnectionString
AccountName:
Value:
Fn::GetAtt:
- RDSAccount
- AccountName