forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
existing-vpc-slb-ecs-isv.yml
348 lines (343 loc) · 9.09 KB
/
existing-vpc-slb-ecs-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
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: Use the existing VPC、VSWitch, create 1 SLB, 2 ECS instances, and bind all ECS
instances to the SLB.
zh-cn: 使用已有VPC、VSWitch,创建1个SLB、2个ECS实例,并将所有ECS实例绑定到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}
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
WaitConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
Properties: {}
WaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Count: 1
Handle:
Ref: WaitConditionHandle
Timeout: 300
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
InstanceRunCommand:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
Fn::GetAtt:
- EcsInstanceGroup
- InstanceIds
CommandContent:
Fn::Sub:
- |
#!/bin/bash
# 挂盘到/disk1
cat >> /root/InitDataDisk.sh << EOF
#!/bin/bash
echo "p
n
p
w
" | fdisk -u /dev/vdb
EOF
/bin/bash /root/InitDataDisk.sh
rm -f /root/InitDataDisk.sh
rm -f InitDataDisk.sh
mkfs -t ext4 /dev/vdb1
cp /etc/fstab /etc/fstab.bak
mkdir /disk1
echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\\\"//g'` /disk1 ext4 defaults 0 0 >> /etc/fstab
mount -a
# 这里配置安装脚本
# yum install -y nginx
# 配置启动脚本
# /usr/sbin/nginx
# 执行成功回调WaitCondition结束waitCondition的等待
${CurlCli} -d "{\"Data\" : \"Success\", \"status\" : \"SUCCESS\"}"
- CurlCli:
Fn::GetAtt:
- WaitConditionHandle
- CurlCli
Type: RunShellScript
Timeout: 300
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
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
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: 负载均衡配置
TemplateTags:
- acs:example:ISV软件部署:创建两个ECS和SLB并将ECS添加到SLB后端服务器