-
Notifications
You must be signed in to change notification settings - Fork 35
/
existing-vpc-slb-ecs-rds-isv.yml
419 lines (418 loc) · 11.7 KB
/
existing-vpc-slb-ecs-rds-isv.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
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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 在现有VPC/VSwitch下,配置安全组,部署1 RDS、1内网SLB,以及2台ECS实例,并将ECS实例加入SLB后端。
en: Configure security groups under the existing VPC/VSwitch, deploy 1 RDS instance,
1 internal SLB, and 2 ECS instances. Subsequently, add the ECS instances to the
backend of the SLB.
Parameters:
ZoneId:
Type: String
Label:
en: VSwitch Availability Zone
zh-cn: 交换机可用区
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
VpcId:
Type: String
Label:
en: VPC ID
zh-cn: 专有网络VPC实例ID
Description:
en: Please search the ID starting with (vpc-xxx) from console-Virtual Private
Cloud
zh-cn: 现有虚拟专有网络的实例ID
AssociationProperty: ALIYUN::ECS::VPC::VPCId
VSwitchId:
Type: String
Label:
en: VSwitch ID
zh-cn: 交换机实例ID
Description:
en: Instance ID of existing business network switches, console-Virtual Private
Cloud-VSwitches under query
zh-cn: 现有业务网络交换机的实例ID
AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
AssociationPropertyMetadata:
VpcId: ${VpcId}
ZoneId: ${ZoneId}
PayType:
Type: String
Label:
en: ECS Instance Charge Type
zh-cn: 付费类型
AssociationProperty: ChargeType
AssociationPropertyMetadata:
LocaleKey: InstanceChargeType
Default: PostPaid
AllowedValues:
- PostPaid
- PrePaid
PayPeriodUnit:
Type: String
Label:
en: Pay Period Unit
zh-cn: 购买资源时长周期
Description:
en: The long cycle of purchasing resources. <br>Week is a Week and Month is
a Month. <br> The default value is month.<br><b><font color='red'> When ECS
instance types are PrePaid valid </b></font>
zh-cn: 购买资源时长的周期。<br>Week为周,Month为月<br>默认值为月<br><b><font color='red'>当ECS实例类型为PrePaid有效</b></font>
AssociationProperty: PayPeriodUnit
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Not:
Fn::Equals:
- ${PayType}
- PostPaid
Default: Month
AllowedValues:
- Month
- Year
PayPeriod:
Type: Number
Label:
en: Period
zh-cn: 购买资源时长
AssociationProperty: PayPeriod
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Not:
Fn::Equals:
- ${PayType}
- PostPaid
Default: 1
AllowedValues:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
EcsInstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例类型
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ${ZoneId}
InstanceChargeType: ${InstanceChargeType}
InstancePassword:
Type: String
Label:
en: Instance Password
zh-cn: 实例密码
Description:
en: Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol
in)
zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
ConstraintDescription:
en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers,
()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
AssociationProperty: ALIYUN::ECS::Instance::Password
AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
MinLength: 8
MaxLength: 30
NoEcho: true
LoadBalancerSpec:
Type: String
Label:
en: LoadBalancer Specifications
zh-cn: 负载均衡实例规格
AssociationProperty: ALIYUN::SLB::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ${ZoneId}
DBMasterUsername:
Type: String
Label:
zh-cn: 数据库账号名称
en: DB Username
Description:
en: Primary account name of the database instance.
zh-cn: 数据库实例的主账号名称。
ConstraintDescription:
en: Consist of 2 to 16 characters of lowercase letters, underline. Must begin
with a letter and be end with an alphanumeric character
zh-cn: 由 2 到 16 个小写字母组成,下划线。必须以字母开头,以字母数字字符结尾
Default: rdsuser
MinLength: 2
MaxLength: 16
DBMasterPassword:
Type: String
Label:
en: Instance Password
zh-cn: 实例密码
Description:
en: Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol
in)
zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
ConstraintDescription:
en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers,
()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
MinLength: 8
MaxLength: 30
NoEcho: true
Resources:
EcsSecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: VpcId
SecurityGroupName: agent-sg
SecurityGroupIngress:
- PortRange: 80/80
Priority: 1
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: internet
SecurityGroupEgress:
- PortRange: -1/-1
Priority: 1
IpProtocol: all
DestCidrIp: 0.0.0.0/0
NicType: internet
- PortRange: -1/-1
Priority: 1
IpProtocol: all
DestCidrIp: 0.0.0.0/0
NicType: intranet
EcsInstanceGroup:
Type: ALIYUN::ECS::InstanceGroup
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitchId
SecurityGroupId:
Ref: EcsSecurityGroup
ImageId: centos_7
InstanceChargeType:
Ref: PayType
PeriodUnit:
Ref: PayPeriodUnit
Period:
Ref: PayPeriod
IoOptimized: optimized
SystemDiskCategory: cloud_essd
SystemDiskSize: 200
DiskMappings:
- Category: cloud_essd
Size: 200
MaxAmount: 2
InstanceType:
Ref: EcsInstanceType
Password:
Ref: InstancePassword
AllocatePublicIP: false
Database:
Type: ALIYUN::RDS::DBInstance
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitchId
Engine: MySQL
EngineVersion: '5.7'
DBInstanceClass: rds.mysql.t1.small
DBInstanceStorage: 200
DBInstanceStorageType: local_ssd
DBInstanceNetType: Intranet
Category: HighAvailability
MasterUserPassword:
Ref: DBMasterPassword
MasterUsername:
Ref: DBMasterUsername
PayType:
Ref: PayType
PeriodType:
Ref: PayPeriodUnit
Period:
Ref: PayPeriod
SecurityIPList:
Fn::Join:
- ','
- Fn::GetAtt:
- EcsInstanceGroup
- PrivateIps
Slb:
Type: ALIYUN::SLB::LoadBalancer
Properties:
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitchId
LoadBalancerName:
Fn::Join:
- '-'
- - StackId
- Ref: ALIYUN::StackId
PayType:
Ref: PayType
PricingCycle:
Ref: PayPeriodUnit
Duration:
Ref: PayPeriod
AddressType: intranet
LoadBalancerSpec:
Ref: LoadBalancerSpec
AutoPay: true
SlbBackendServerAttachment:
Type: ALIYUN::SLB::BackendServerAttachment
Properties:
BackendServerList:
Fn::GetAtt:
- EcsInstanceGroup
- InstanceIds
LoadBalancerId:
Ref: Slb
BackendServerWeightList:
- 100
- 100
DependsOn:
- EcsInstanceGroup
SlbListener:
Type: ALIYUN::SLB::Listener
Properties:
Persistence:
CookieTimeout: 60
StickySession: 'on'
PersistenceTimeout: 180
XForwardedFor: 'off'
StickySessionType: insert
ListenerPort: 3306
Bandwidth: -1
HealthCheck:
HttpCode: http_2xx,http_3xx,http_4xx,http_5xx
HealthCheckType: tcp
UnhealthyThreshold: 3
Timeout: 5
HealthyThreshold: 3
Port: 3306
URI: /
Interval: 2
LoadBalancerId:
Ref: Slb
BackendServerPort: 3306
Protocol: tcp
DependsOn:
- Slb
WaitConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
Properties: {}
WaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Count: 1
Handle:
Ref: WaitConditionHandle
Timeout: 300
DependsOn:
- Database
- EcsInstanceGroup
InstanceRunCommand:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
Fn::GetAtt:
- EcsInstanceGroup
- InstanceIds
CommandContent:
Fn::Sub:
- |
#!/bin/bash
cat >> /root/conf.txt << EOF
DBMasterUsername=${DBMasterUsername}
DBMasterPassword=${DBMasterPassword}
DBConnectString=${DBConnectString}
EOF
# 继续进行初始化 在这里补上自己的代码 数据库的初始化可以用shell mysqldump完成
# init.sh /root/conf.txt
# init.sh ${DBMasterUsername} ${DBMasterPassword} ${DBConnectString} 也是可以的
# 执行成功回调WaitCondition结束waitCondition的等待
${CurlCli} -d "{\"Data\" : \"Success\", \"status\" : \"SUCCESS\"}"
- DBMasterUsername:
Ref: DBMasterUsername
DBMasterPassword:
Ref: DBMasterPassword
DBConnectString:
Fn::GetAtt:
- Database
- InnerConnectionString
CurlCli:
Fn::GetAtt:
- WaitConditionHandle
- CurlCli
Type: RunShellScript
Timeout: 300
Outputs:
SlbIpAddress:
Description:
en: The IP address of the load balancer.
zh-cn: 负载均衡器的IP地址。
Value:
Fn::GetAtt:
- Slb
- IpAddress
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- ZoneId
Label:
default:
zh-cn: 可用区配置
en: Zone Configuration
- Parameters:
- VpcId
- VSwitchId
- SecurityGroupId
Label:
default:
zh-cn: 选择已有基础资源配置
en: Choose existing Infrastructure Configuration
- Parameters:
- PayType
- PayPeriodUnit
- PayPeriod
Label:
default:
en: PayType Configuration
zh-cn: 付费类型
- Parameters:
- EcsInstanceType
- InstancePassword
Label:
default:
en: Instance Configure
zh-cn: ECS实例配置
- Parameters:
- LoadBalancerSpec
Label:
default:
en: SLB Configure
zh-cn: SLB负载均衡配置
- Parameters:
- DBInstanceClass
- DBInstanceStorage
- DBInstanceStorageType
- DBMasterUsername
- DBMasterPassword
Label:
default:
en: Database
zh-cn: RDS数据库配置
TemplateTags:
- acs:example:ISV软件部署:创建两个ECS和SLB并将ECS添加到SLB后端服务器,并创建一台RDS