-
Notifications
You must be signed in to change notification settings - Fork 35
/
one-ecs-attach-multiple-slb.yml
373 lines (369 loc) · 11.5 KB
/
one-ecs-attach-multiple-slb.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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建ECS实例,配置VPC与交换机,加入3个SLB(支持内网/外网),并在实例/etc/hosts中自动绑定IP与主机名。
en: Create an ECS instance, configure the VPC and switch, add 3 SLBs (supporting
both internal and external networks), and automatically bind IP addresses with
hostnames in the instance's /etc/hosts file.
Parameters:
VpcCidrBlock:
Type: String
Label:
en: Amount
zh-cn: 专有网络网段
Description:
en: 'The IP address range of the VPC in the CIDR Block form; <br>You can use
the following IP address ranges and their subnets: <br><font color=''green''>[10.0.0.0/8]</font><br><font
color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>'
zh-cn: VPC的IP地址范围;<br>您可以使用以下IP地址范围及其子网:<br><font color='green'>[10.0.0.0/8]</font><br><font
color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0/16]</font>
Default: 192.168.0.0/16
ZoneId:
Type: String
Label:
en: Zone ID
zh-cn: 可用区ID
Description:
en: Available Zone ID,</font><a href='https://www.alibabacloud.com/help/doc-detail/123712.html'
target='_blank'><b> View region and zone info</b><font color='blue'></a>
zh-cn: 可用区Id,</font><a href='https://help.aliyun.com/document_detail/123712.html'
target='_blank'><b> 查看可用区信息</b><font color='blue'></a>
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
VSwitchCidrBlock:
Type: String
Label:
en: VSwitch CIDR block
zh-cn: 交换机子网网段
Description:
en: CIDR Block of created VSwitch,It must belong to itself VPC CIDR Block.
zh-cn: 创建的虚拟交换机的子网,它必须属于自己的VPC网段内
Default: 192.168.1.0/24
LoadBalancerAddressType:
Type: String
Label:
en: Load Balancer Address Type
zh-cn: 负载均衡器地址类型
Description:
en: The address type of the load balancer. "intranet" or "internet".
zh-cn: 负载平衡器的地址类型。intranet(内联网)或internet(互联网)
Default: internet
LoadBalancerSpec:
Type: String
Label:
en: Load Balancer Spec
zh-cn: 负载均衡器实例类型
Description:
en: The specification of the Server Load Balancer Instance, <a href='https://www.alibabacloud.com/help/doc-detail/85939.html'
target='_blank'><b> View spec info</b><font color='blue'></a>
zh-cn: 服务器负载均衡器实例的类型,<a href='https://help.aliyun.com/knowledge_detail/67982.html'
target='_blank'><b>规格信息</b><font color='blue'></a>
Default: slb.s1.small
ImageId:
Type: String
Label:
en: Image ID
zh-cn: 镜像ID
Description:
en: Image ID, represents the image resource to startup one ECS instance, <font><a
href='https://www.alibabacloud.com/help/doc-detail/112977.html' target='_blank'><b>View
image resources</b></font color='blue'></a>
zh-cn: 镜像ID,ECS实例的镜像资源, <font><a href='https://help.aliyun.com/document_detail/112977.html'
target='_blank'><b>查看镜像资源</b></font color='blue'></a>
AssociationProperty: ALIYUN::ECS::Image::ImageId
AssociationPropertyMetadata:
InstanceType: ${InstanceType}
SupportedImageOwnerAlias:
- system
- self
- others
Default: centos_7_04_64_20G_alibase_201701015.vhd
InstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例类型
Description:
en: The ECS instance type,go to the product console to ensure the current instance
is available, <font><a href='https://www.alibabacloud.com/help/doc-detail/25378.html'
target='_blank'><b>View instance types</b></font color='blue'></a>
zh-cn: ECS实例类型,进入产品控制台确保当前实例可用, <font><a href='https://help.aliyun.com/document_detail/25378.html'
target='_blank'><b>查看实例类型</b></font color='blue'></a>
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ZoneId
MaxAmount:
Type: Number
Label:
en: Amount
zh-cn: 数量
Description:
en: Number of ECS instances.
zh-cn: ECS实例数量。
ConstraintDescription:
en: An integer within [1, 100]
zh-cn: '[1, 100] 内的整数'
Default: 1
MinValue: 1
MaxValue: 100
InternetChargeType:
Type: String
Label:
en: Internet Charge Type
zh-cn: 网络类型
Description:
en: Instance internet access charge type.Support 'PayByBandwidth' and 'PayByTraffic'
only. Default is PayByTraffic
zh-cn: 实例internet访问收费类型。仅支持'PayByBandwidth(按带宽付费)'和'PayByTraffic(按流量付费)'。默认为PayByTraffic
AssociationPropertyMetadata:
LocaleKey: InternetChargeType
Default: PayByTraffic
AllowedValues:
- PayByBandwidth
- PayByTraffic
SystemDiskCategory:
Type: String
Label:
en: System Disk Category
zh-cn: 系统盘类别
AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
AssociationPropertyMetadata:
InstanceType: InstanceType
ZoneId: ZoneId
DataDiskCategory:
Type: String
Label:
en: Data Disk Category
zh-cn: 数据盘类型
AssociationProperty: ALIYUN::ECS::Disk::DataDiskCategory
AssociationPropertyMetadata:
InstanceType: ${InstanceType}
ZoneId: ${ZoneId}
DataDiskSize:
Type: Number
Label:
en: Data Disk Category
zh-cn: 数据盘大小
Description:
en: 'The size of the first volume, unit in GB.Value range: cloud: [5,2000],
cloud_efficiency: [20,32768], cloud_ssd: [20,32768], ephemeral_ssd: [5,800].The
value should be equal to or greater than the specific snapshot.'
zh-cn: 第一个数据盘的大小,单位为GB。值范围:cloud:[5,2000]、cloud_efficiency:[20,32768]、cloud_ssd:[20,32768]、ephemeral_ssd:[5,800]。该值应等于或大于特定快照。
Default: 40
Password:
Type: String
Label:
en: Instance Password
zh-cn: 实例密码
Description:
en: The 8-30 long login password of instance, consists of the uppercase, lowercase
letter and number. <br> special characters include()'~!@#$%^&*_-+=|{}[]:;'<>,.?/.
zh-cn: 长度8-30,必须包含大写字母、小写字母、数字、特殊符号三个;<br>特殊字符包括:()'~!@#$%^&*_-+=|{}[]:;'<>,.?/
ConstraintDescription:
en: 'Length 8-30, must contain upper case letters, lower case letters, Numbers,
special symbols three; special characters include: ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/'
zh-cn: 长度8-30,必须包含大写字母、小写字母、数字、特殊符号三种;特殊字符包括:()`~!@#$%^&*_-+=|{}[]:;' <>,.?/
AllowedPattern: '[a-zA-Z0-9-\(\)\`\~\!@\#\$%\^&\*-+=\|\{\}\[\]\:\;\‘\,\.\?\/]*'
MinLength: 8
MaxLength: 30
NoEcho: true
Resources:
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock:
Ref: VpcCidrBlock
VpcName:
Fn::Join:
- _
- - Vpc
- Ref: ALIYUN::StackId
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: Vpc
SecurityGroupName:
Fn::Join:
- _
- - SecurityGroup
- Ref: ALIYUN::StackId
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
CidrBlock:
Ref: VSwitchCidrBlock
VSwitchName:
Fn::Join:
- _
- - VSwitch
- Ref: ALIYUN::StackId
DependsOn: Vpc
ECSInstanceGroup:
Type: ALIYUN::ECS::InstanceGroup
Properties:
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
ImageId:
Ref: ImageId
AllocatePublicIP: 'false'
DiskMappings:
- Category:
Ref: DataDiskCategory
Size:
Ref: DataDiskSize
InstanceName:
Fn::Join:
- _
- - ECSInstanceGroup
- Ref: ALIYUN::StackId
InstanceType:
Ref: InstanceType
InternetChargeType:
Ref: InternetChargeType
InternetMaxBandwidthOut: 1
IoOptimized: optimized
MaxAmount:
Ref: MaxAmount
Password:
Ref: Password
SystemDiskCategory:
Ref: SystemDiskCategory
UserData:
Fn::Join:
- ''
- - '#!/bin/sh
'
- 'ip_addr=`ifconfig eth0 | awk ''/inet /{print $2}''`
'
- 'host_name=`hostname`
'
- 'echo "$ip_addr $host_name" >> /etc/hosts
'
FirstSLB:
Type: ALIYUN::SLB::LoadBalancer
Properties:
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
AddressType:
Ref: LoadBalancerAddressType
LoadBalancerName:
Fn::Join:
- _
- - FirstSLB
- Ref: ALIYUN::StackId
LoadBalancerSpec:
Ref: LoadBalancerSpec
PayType: PayOnDemand
DependsOn: VSwitch
AttachmentECSToFirstSLB:
Type: ALIYUN::SLB::BackendServerAttachment
Properties:
BackendServerList:
Fn::GetAtt:
- ECSInstanceGroup
- InstanceIds
BackendServerWeightList:
- '100'
LoadBalancerId:
Ref: FirstSLB
SecondSLB:
Type: ALIYUN::SLB::LoadBalancer
Properties:
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
AddressType:
Ref: LoadBalancerAddressType
LoadBalancerName:
Fn::Join:
- _
- - SecondSLB
- Ref: ALIYUN::StackId
LoadBalancerSpec:
Ref: LoadBalancerSpec
PayType: PayOnDemand
DependsOn: VSwitch
AttachmentECSToSecondSLB:
Type: ALIYUN::SLB::BackendServerAttachment
Properties:
BackendServerList:
Fn::GetAtt:
- ECSInstanceGroup
- InstanceIds
BackendServerWeightList:
- '100'
LoadBalancerId:
Ref: SecondSLB
ThirdSLB:
Type: ALIYUN::SLB::LoadBalancer
Properties:
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
AddressType:
Ref: LoadBalancerAddressType
LoadBalancerName:
Fn::Join:
- _
- - ThirdSLB
- Ref: ALIYUN::StackId
LoadBalancerSpec:
Ref: LoadBalancerSpec
PayType: PayOnDemand
DependsOn: VSwitch
AttachmentECSToThirdSLB:
Type: ALIYUN::SLB::BackendServerAttachment
Properties:
BackendServerList:
Fn::GetAtt:
- ECSInstanceGroup
- InstanceIds
BackendServerWeightList:
- '100'
LoadBalancerId:
Ref: ThirdSLB
Outputs:
InstanceIds:
Description: The instance id list of created ecs instance.
Value:
Fn::GetAtt:
- ECSInstanceGroup
- InstanceIds
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- VpcCidrBlock
- ZoneId
- VSwitchCidrBlock
Label:
default: VPC
- Parameters:
- LoadBalancerAddressType
- LoadBalancerSpec
Label:
default: SLB
- Parameters:
- InstanceType
- ImageId
- MaxAmount
- InternetChargeType
- SystemDiskCategory
- DataDiskCategory
- DataDiskSize
- Password
Label:
default: ECS
TemplateTags:
- acs:example:网络:创建ECS加入多个SLB并在/etc/hosts中绑定IP和机器名