-
Notifications
You must be signed in to change notification settings - Fork 35
/
mobile-application-direct-transmission-service.yml
267 lines (267 loc) · 7.56 KB
/
mobile-application-direct-transmission-service.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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建RAM角色与用户,配置ECS实例,安装App服务器,开放安全组端口,通过EIP和7080端口获取STS临时Token。
en: Create RAM roles and users, configure ECS instances, install the application
server, open security group ports, and acquire STS temporary Tokens through EIP
on port 7080.
Parameters:
ZoneId:
Type: String
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
AssociationPropertyMetadata:
AutoSelectFirst: true
Label:
en: Availability Zone
zh-cn: 可用区
InstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例类型
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
ZoneId: ${ZoneId}
Label:
en: Instance Type
zh-cn: 实例规格
Password:
NoEcho: true
Type: String
Description:
en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
Label:
en: ECS Instance Password
zh-cn: ECS实例密码
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
Resources:
Role:
Type: ALIYUN::RAM::Role
Properties:
RoleName: AliyunOSSTokenGeneratorRoleByRos
Description: 访问OSS的权限
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
RAM:
- Fn::Sub: acs:ram::${ALIYUN::TenantId}:root
Version: '1'
Policies:
- PolicyName: AliyunOSSTokenGeneratorRolePolicyByRos
Description: 此Policy由ROS创建,用于限制角色AliyunOSSTokenGeneratorRole的权限
PolicyDocument:
Version: '1'
Statement:
- Effect: Allow
Action:
- oss:*
Resource:
- '*'
User:
Type: ALIYUN::RAM::User
Properties:
UserName: AliyunOSSTokenGeneratorUserByRos
Policies:
- PolicyName: AliyunOSSTokenGeneratorUserPolicyByRos
PolicyDocument:
Version: '1'
Statement:
- Effect: Allow
Action:
- sts:AssumeRole
Resource:
- Fn::GetAtt:
- Role
- Arn
AccessKey:
Type: ALIYUN::RAM::AccessKey
Properties:
UserName:
Fn::GetAtt:
- User
- UserName
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock: 192.168.0.0/16
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: Vpc
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
CidrBlock: 192.168.0.0/24
InstanceGroup:
Type: ALIYUN::ECS::InstanceGroup
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
ImageId: centos_7
InstanceType:
Ref: InstanceType
SystemDiskCategory: cloud_essd
SystemDiskSize: 40
MaxAmount: 1
InternetMaxBandwidthOut: 5
Password:
Ref: Password
AllocatePublicIP: false
Eip:
Type: ALIYUN::VPC::EIP
Properties:
Name: create_by_document
InternetChargeType: PayByTraffic
Bandwidth: 5
EipAssociation:
Type: ALIYUN::VPC::EIPAssociation
Properties:
InstanceId:
Fn::Select:
- 0
- Fn::GetAtt:
- InstanceGroup
- InstanceIds
AllocationId:
Fn::GetAtt:
- Eip
- AllocationId
ServerCommand:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
Fn::GetAtt:
- InstanceGroup
- InstanceIds
Type: RunShellScript
Sync: true
Timeout: 3600
CommandContent:
Fn::Sub: |-
yum -y install unzip java
wget -O AppTokenServerDemo.zip 'https://gosspublic.alicdn.com/doc31920servercode/AppTokenServerDemo.zip?spm=a2c4g.31920.0.0.65f768f3jSxBXC&file=AppTokenServerDemo.zip'
unzip -o AppTokenServerDemo.zip
cd AppTokenServerDemo
echo -e '{\n "AccessKeyID": "${AccessKey.AccessKeyId}",\n "AccessKeySecret": "${AccessKey.AccessKeySecret}",\n "RoleArn": "${Role.Arn}",\n "TokenExpireTime": "3600",\n "PolicyFile": "policy/bucket_write_policy.txt"\n}' > config.json
nohup java -jar app-token-server.jar &
SecurityGroupIngress_22:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SecurityGroupId:
Ref: SecurityGroup
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 22/22
SecurityGroupIngress_80:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SecurityGroupId:
Ref: SecurityGroup
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 80/80
SecurityGroupIngress_443:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SecurityGroupId:
Ref: SecurityGroup
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 443/443
SecurityGroupIngress_7080:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SecurityGroupId:
Ref: SecurityGroup
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 7080/7080
Outputs:
RoleArn:
Description:
en: Role ARN.
zh-cn: 角色的ARN。
Value:
Fn::GetAtt:
- Role
- Arn
AccessKeyId:
Description: AccessKey ID.
Value:
Fn::GetAtt:
- AccessKey
- AccessKeyId
Console.ApplicationServerAddress:
Label:
en: Application server address
zh-cn: 应用服务端地址
Value:
Fn::Sub: http://${Eip.EipAddress}:7080
EcsInstanceId:
Description:
en: Ecs instance id.
zh-cn: ECS实例id。
Value:
Fn::Select:
- 0
- Fn::GetAtt:
- InstanceGroup
- InstanceIds
EipAllocationId:
Description:
en: Eip allocation id.
zh-cn: EIP实例id。
Value:
Fn::GetAtt:
- Eip
- AllocationId
EcsLoginAddress:
Description:
en: Ecs login address.
zh-cn: ECS登录地址。
Value:
Fn::Sub:
- https://ecs-workbench.aliyun.com/?from=EcsConsole&instanceType=ecs®ionId=${Region}&instanceId=${InstanceId}
- Region:
Ref: ALIYUN::Region
InstanceId:
Fn::Select:
- 0
- Fn::GetAtt:
- InstanceGroup
- InstanceIds
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- ZoneId
- InstanceType
- Password
Label:
default:
zh-cn: ECS实例配置信息
en: Instance
TemplateTags:
- acs:document-help:oss:快速搭建移动应用直传服务