-
Notifications
You must be signed in to change notification settings - Fork 35
/
cdn-speeds-up-oss-access.yml
185 lines (185 loc) · 5.53 KB
/
cdn-speeds-up-oss-access.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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建CDN域加速OSS访问,自动开启CDN服务,配置源站及DNS解析记录。
en: Create a CDN domain to accelerate OSS access, automatically enabling the CDN
service, and configure the origin server and DNS resolution records.
Conditions:
CreateBucketConditions:
Fn::Equals:
- true
- Ref: WhetherCreateBucket
Parameters:
WhetherCreateBucket:
Type: Boolean
Label:
en: WhetherCreateBucket
zh-cn: 是否新建OSS Bucket
Default: true
NewBucketName:
Default: null
Type: String
Label:
en: NewBucketName
zh-cn: 新建OSS Bucket名称
Description:
en: Bucket names must be globally unique within the scope of OSS. The length
is 3~63 characters. Must start and end with a lowercase English letter or
number, and can contain lowercase English letters, numbers, and dashes (-).
zh-cn: Bucket 名称在 OSS 范围内必须全局唯一。长度为3~63个字符。必须以小写英文字母或数字开头和结尾,可包含小写英文字母、数字和短划线(-)。
AssociationProperty: AutoCompleteInput
AssociationPropertyMetadata:
Length: 6
Prefix: test-bucketname-
CharacterClasses:
- Class: lowercase
min: 1
Visible:
Condition:
Fn::Equals:
- ${WhetherCreateBucket}
- true
AllowedPattern: ^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$
ExistBucketName:
Type: String
Label:
en: Exist BucketName
zh-cn: 选择已有OSS Bucket
AssociationProperty: ALIYUN::OSS::Bucket::BucketName
AssociationPropertyMetadata:
RegionId: ${ALIYUN::Region}
Visible:
Condition:
Fn::Equals:
- ${WhetherCreateBucket}
- false
Default: ''
Scope:
Type: String
Label:
zh-cn: 加速区域
en: Region
Description:
zh-cn: 加速区域含中国内地时(domestic或global),加速域名必须备案,且账号必须实名认证。
en: When the acceleration region includes mainland China(domestic or global), the accelerated domain must be registered (ICP license), and the account must be verified (real-name authentication).
Default: domestic
AllowedValues:
- domestic
- overseas
- global
DomainName:
Type: String
Label:
zh-cn: 加速域名
en: Accelerated domain name
Description:
zh-cn: 加速域名是指接入CDN,用于加速源站的域名。该示例为oss.example.com。
en: Accelerated domain name refers to the domain name of the access CDN used to accelerate the source site. The example is oss.example.com.
Default: oss.example.com
Resources:
OSSBucket:
Type: ALIYUN::OSS::Bucket
Condition: CreateBucketConditions
Properties:
BucketName:
Fn::If:
- CreateBucketConditions
- Ref: NewBucketName
- Ref: ExistBucketName
DeletionForce: true
CORSConfiguration:
CORSRule:
- AllowedHeader:
- '*'
AllowedMethod:
- POST
AllowedOrigin:
- '*'
MaxAgeSeconds: 0
DomainConfig:
DependsOn: Domain
Type: ALIYUN::CDN::DomainConfig
Properties:
FunctionList:
- FunctionArgs:
- ArgName: private_oss_auth
ArgValue: 'on'
- ArgName: perm_private_oss_tbl
ArgValue: ''
FunctionName: l2_oss_key
DomainNames:
Ref: DomainName
OpenCdnService:
Type: ALIYUN::ROS::AutoEnableService
Properties:
ServiceName: CDN
Domain:
Type: ALIYUN::CDN::Domain
Properties:
Sources:
Fn::If:
- CreateBucketConditions
- Fn::Sub: '[{"content":"${NewBucketName}.oss-${ALIYUN::Region}.aliyuncs.com", "type":"oss", "priority":"20", "port":80, "weight":"10"}]'
- Fn::Sub: '[{"content":"${ExistBucketName}.oss-${ALIYUN::Region}.aliyuncs.com", "type":"oss", "priority":"20", "port":80, "weight":"10"}]'
Scope:
Ref: Scope
CdnType: web
DomainName:
Ref: DomainName
DependsOn:
- OpenCdnService
- OSSBucket
DomainRecord:
Type: ALIYUN::DNS::DomainRecord
Properties:
Type: CNAME
RR:
Fn::Select:
- '0'
- Fn::Split:
- .
- Ref: DomainName
Value:
Fn::GetAtt:
- Domain
- Cname
DomainName:
Fn::Join:
- .
- - Fn::Select:
- '1'
- Fn::Split:
- .
- Ref: DomainName
- Fn::Select:
- '2'
- Fn::Split:
- .
- Ref: DomainName
DependsOn: Domain
Outputs:
Console.Cname:
Label: CNAME
Description: CNAME
Value:
Fn::GetAtt:
- Domain
- Cname
Console.Bucket:
Label:
zh-cn: Bucket
en: Bucket
Description:
zh-cn: 文件上传到的bucket控制台页面。可访问该链接查看上传情况。
en: Bucket console page, view upload status.
Value:
Fn::If:
- CreateBucketConditions
- Fn::Sub: https://oss.console.aliyun.com/bucket/oss-${ALIYUN::Region}/${NewBucketName}
- Fn::Sub: https://oss.console.aliyun.com/bucket/oss-${ALIYUN::Region}/${ExistBucketName}
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- DomainName
TemplateTags:
- acs:document-help:oss:使用CDN加速OSS访问