forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
add-signatures-on-the-client-by-using-JS-and-upload-data.yml
224 lines (223 loc) · 7.26 KB
/
add-signatures-on-the-client-by-using-JS-and-upload-data.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
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: use JavaScript to add signatures on the client based on POST policies and then
upload data to Object Storage Service (OSS) by using form upload.
zh-cn: 基于POST Policy的使用规则在客户端通过JavaScript代码完成签名,然后通过表单直传数据到OSS。
Parameters:
OSSBucketName:
Type: String
Label:
en: OSS bucket name
zh-cn: 对象存储空间的名称
Description:
en: Name of OSS bucket, [2, 128] English.
zh-cn: 对象存储空间的名称,[2,128]英文。
Default: examplebucket
AllowedPattern: '[-_a-zA-Z0-9]{2,128}$'
MinLength: 2
MaxLength: 128
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
InstanceType:
Type: String
Label:
en: ECS Instance Type
zh-cn: ECS实例类型
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
SystemDiskCategory:
Type: String
Label:
en: System Disk Category
zh-cn: 系统盘类别
Description:
en: '<font color=''blue''><b>Optional values:</b></font><br>[cloud_efficiency:
<font color=''green''>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color=''green''>SSD
Cloud Disk</font>]<br>[cloud_essd: <font color=''green''>ESSD Cloud Disk</font>]<br>[cloud:
<font color=''green''>Cloud Disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local
SSD Cloud Disk</font>]'
zh-cn: '<font color=''blue''><b>可选值:</b></font><br>[cloud_efficiency: <font
color=''green''>高效云盘</font>]<br>[cloud_ssd: <font color=''green''>SSD云盘</font>]<br>[cloud_essd:
<font color=''green''>ESSD云盘</font>]<br>[cloud: <font color=''green''>普通云盘</font>]<br>[ephemeral_ssd:
<font color=''green''>本地SSD盘</font>]'
Default: cloud_ssd
AllowedValues:
- cloud_efficiency
- cloud_ssd
- cloud
- cloud_essd
- ephemeral_ssd
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: 10.0.0.0/8
VpcName:
Fn::Join:
- _
- - Vpc
- Ref: ALIYUN::StackId
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: Vpc
SecurityGroupName:
Fn::Join:
- _
- - SecurityGroup
- Ref: ALIYUN::StackId
SecurityGroupType: normal
SecurityGroupIngress:
- PortRange: -1/-1
IpProtocol: all
SourceCidrIp: 0.0.0.0/0
SecurityGroupEgress:
- PortRange: -1/-1
IpProtocol: all
DestCidrIp: 0.0.0.0/0
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Fn::GetAtt:
- Vpc
- VpcId
CidrBlock: 10.0.10.0/24
DependsOn: Vpc
WebServer:
Type: ALIYUN::ECS::Instance
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
ImageId: ubuntu
AllocatePublicIP: true
InstanceType:
Ref: InstanceType
Password:
Ref: Password
SystemDiskCategory:
Ref: SystemDiskCategory
SystemDiskDiskName: SystemDisk
SystemDiskSize: 40
OSSBucket:
Type: ALIYUN::OSS::Bucket
Properties:
BucketName:
Ref: OSSBucketName
DeletionForce: true
CORSConfiguration:
CORSRule:
- AllowedHeader:
- '*'
AllowedMethod:
- POST
AllowedOrigin:
- '*'
MaxAgeSeconds: 0
InstanceRunCommand:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
- Ref: WebServer
Type: RunShellScript
CommandContent:
Fn::Sub:
- |
#!/bin/bash
sudo apt update
sudo apt-get install -y unzip
sudo apt-get install -y apache2
cd /var/www/html
wget https://gosspublic.alicdn.com/doc/oss-h5-upload-js-direct.zip
unzip oss-h5-upload-js-direct.zip
rm oss-h5-upload-js-direct.zip
cd oss-h5-upload-js-direct
sed -i 's/6MKOqxGiGU4AUk44/${AccessKey.AccessKeyId}/' upload.js
sed -i 's/ufu7nS8kS59awNihtjSonMETLI0KLy/${AccessKey.AccessKeySecret}/' upload.js
sed -i 's/post-test.oss-cn-hangzhou/${OSSBucketName}.oss-${RegionId}/' upload.js
sed -i 's/2020-01-01T12:00:00.000Z/2040-01-01T12:00:00.000Z/' upload.js
mv * /var/www/html
- OSSBucketName:
Ref: OSSBucketName
RegionId:
Ref: ALIYUN::Region
Timeout: 3600
Sync: true
User:
Type: ALIYUN::RAM::User
Properties:
UserName:
Fn::Sub: create_by_document-${ALIYUN::StackId}
PolicyAttachments:
System:
- AliyunOSSFullAccess
AccessKey:
Type: ALIYUN::RAM::AccessKey
Properties:
UserName:
Ref: User
Outputs:
UploadPath:
Description:
en: Client html page.
zh-cn: 客户端测试页面。可访问该链接测试文件上传。
Value:
Fn::Sub:
- http://${IP}
- IP:
Fn::GetAtt:
- WebServer
- PublicIp
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- OSSBucketName
- ZoneId
- InstanceType
- SystemDiskCategory
- Password
TemplateTags:
- acs:document-help:oss:JavaScript客户端签名直传