ALIYUN::OSS::Bucket类型用于创建OSS存储空间。
语法
{
"Type": "ALIYUN::OSS::Bucket",
"Properties": {
"AccessControl": String,
"RefererConfiguration": Map,
"ServerSideEncryptionConfiguration": Map,
"CORSConfiguration": Map,
"Tags": Map,
"LoggingConfiguration": Map,
"LifecycleConfiguration": Map,
"StorageClass": String,
"DeletionForce": Boolean,
"Policy": Map,
"BucketName": String,
"RedundancyType": String,
"VersioningConfiguration": Map,
"ResourceGroupId": String,
"EnableOssHdfsService": Boolean,
"WebsiteConfigurationV2": Map,
"BlockPublicAccess": Boolean
}
}属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
BucketName | String | 是 | 否 | 存储空间名称。 | 长度为3~63个字符。必须以小写英文字母或数字开头和结尾,可包含小写英文字母、数字和短划线(-)。 说明 此名称要求全局唯一,可以通过使用AssociationProperty中的AutoCompleteInput自动生成随机字符串。更多信息,请参见如何控制随机字符串的长度?。 |
AccessControl | String | 否 | 是 | 访问权限。 | 取值:
|
CORSConfiguration | Map | 否 | 是 | 跨域访问配置。 | 更多信息,请参见CORSConfiguration属性。 |
DeletionForce | Boolean | 否 | 是 | 是否强制删除OSS中的文件。 | 取值:
|
EnableOssHdfsService | Boolean | 否 | 是 | 是否开启OSS-HDFS服务。 | 取值:
|
BlockPublicAccess | Boolean | 否 | 是 | 是否为指定Bucket开启阻止公共访问。 | 取值:
|
LifecycleConfiguration | Map | 否 | 是 | 文件生命周期配置。 | 更多信息,请参见LifecycleConfiguration属性。 |
LoggingConfiguration | Map | 否 | 否 | 日志存储配置。 | 更多信息,请参见LoggingConfiguration属性。 |
Policy | Map | 否 | 是 | 存储空间策略。 | 更多信息,请参见Bucket Policy常见示例。 |
RedundancyType | String | 否 | 否 | Bucket的数据容灾类型。 | 取值:
|
RefererConfiguration | Map | 否 | 是 | 防盗链配置。 | 更多信息,请参见RefererConfiguration属性。 |
ResourceGroupId | String | 否 | 否 | 资源组ID。 | 无 |
ServerSideEncryptionConfiguration | Map | 否 | 是 | 服务端加密规则配置。 | 更多信息,请参见ServerSideEncryptionConfiguration属性。 |
StorageClass | String | 否 | 否 | 存储空间类型。 | 取值:
|
Tags | Map | 否 | 是 | 存储空间标签。Key-Value形式的键值对。 | 最多设置20个标签。 Key长度为1~64个字符,不能以 Value长度为0~128个字符,必须为UTF-8编码。 |
VersioningConfiguration | Map | 否 | 是 | 保存版本控制状态的容器。 | 更多信息,请参见VersioningConfiguration属性。 |
WebsiteConfigurationV2 | Map | 否 | 否 | 网站配置。 | 更多信息,请参见WebsiteConfigurationV2属性。 |
CORSConfiguration语法
"CORSConfiguration": {
"CORSRule": List,
"ResponseVary": Boolean
}CORSConfiguration属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
CORSRule | List | 否 | 是 | 跨域访问规则。 | 更多信息,请参见CORSRule属性。 |
ResponseVary | Boolean | 否 | 是 | 是否返回 | 其取值范围如下:
说明 注意:此字段不能单独配置;必须至少配置一条跨域规则才能生效。 |
CORSRule语法
"CORSRule": [
{
"MaxAgeSeconds": Number,
"AllowedMethod": List,
"ExposeHeader": List,
"AllowedOrigin": List,
"AllowedHeader": List
}
]CORSRule属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
AllowedHeader | List | 否 | 是 | 允许的跨域请求Header。 | 取值:
|
AllowedMethod | List | 否 | 是 | 允许的跨域请求的方法。 | 取值:
|
AllowedOrigin | List | 否 | 是 | 允许的跨域请求的来源。 | 无 |
ExposeHeader | List | 否 | 是 | 允许用户从应用程序中访问的响应头。 | 不允许使用星号(*)。 |
MaxAgeSeconds | Number | 否 | 是 | 浏览器对特定资源的OPTIONS请求返回结果的缓存时间。 | 无 |
LifecycleConfiguration语法
"LifecycleConfiguration": {
"Rule": List
}LifecycleConfiguration属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Rule | List | 是 | 否 | 生命周期规则。 | 更多信息,请参见Rule属性。 |
Rule语法
"Rule": [
{
"Status": String,
"AbortMultipartUpload": Map,
"Expiration": Map,
"Prefix": String,
"ID": String,
"Filter": Map,
"Transition": List
}
]Rule属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Prefix | String | 是 | 否 | 规则所适用的前缀。 | 只有匹配前缀的对象才可能被该规则所影响。 |
AbortMultipartUpload | Map | 否 | 否 | 未完成分片上传的过期属性。 | 更多信息,请参见AbortMultipartUpload属性。 |
Expiration | Map | 否 | 否 | 对象规则的过期属性。 | 更多信息,请参见Expiration属性。 |
ID | String | 否 | 否 | 规则的唯一ID。 | 最长为255字符。当没有指定ID或者ID为空时,OSS会自动生成一个唯一值。 |
Status | String | 否 | 是 | 启用或停用规则。 | 取值:
|
Filter | Map | 否 | 否 | 这条排除规则最多只有一个条件规则。 | 更多信息,请参见Filter属性。 |
Transition | List | 否 | 否 | 存储冗余转换任务列表 | 更多信息,请参考Transition属性。 |
Transition语法
"Transition": [
{
"CreatedBeforeDate": String,
"Days": Integer,
"IsAccessTime": Boolean,
"ReturnToStdWhenVisit": Boolean,
"AllowSmallFile": Boolean,
"StorageClass": String
}
]Transition属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
CreatedBeforeDate | String | 否 | 否 | 指定一个日期;OSS 将对最后修改时间早于该日期的数据应用生命周期规则。 | 该日期必须符合 ISO8601 格式,且必须为 UTC 时间的午夜(即 00:00:00)。 |
Days | Integer | 否 | 否 | 指定对象最后一次更新后多少天生效生命周期规则。 | 取值范围:正整数(例如:30、90、180 等)。 |
IsAccessTime | Boolean | 否 | 否 | 指定生命周期规则是否基于对象的最后访问时间来应用。 |
|
ReturnToStdWhenVisit | Boolean | 否 | 否 | 指定是否在非标准类型对象被访问后,将其存储类别恢复为标准类型。 | 此选项仅在将 IsAccessTime 元素设置为 true 时生效。 |
AllowSmallFile | Boolean | 否 | 否 | 指定是否根据对象的最后访问时间。 | 将其存储类别更改为 IA、归档(Archive)或冷归档(Cold Archive),前提是对象大小小于 64 KB。 |
StorageClass | String | 否 | 否 | 对象被更改后的存储类别。 | 取值:
|
Filter语法
"Filter":{
"Not": Map
}Filter属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Not | Map | 否 | 否 | 排除规则 | 更多信息,请参见Not属性。 |
Not语法
"Not":{
"Tag": List,
"Prefix": String
}Not属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Tag | List | 否 | 否 | 排除规则的标签。 | 这条排除规则最多适用于一个对象标签。 |
Prefix | String | 否 | 否 | 规则前缀。 | 此排除规则所适用的对象前缀条件如下:
简而言之,这条规则说明了在设置排除规则时,如果上级规则定义了一个前缀,那么下属的非规则内的前缀必须是上级前缀的子集或具体化,且不能完全相同(除非使用了标签配置)。这样设计是为了实现更细致和灵活的文件或对象筛选逻辑,特别是在云存储、数据备份或内容过滤等场景中。 |
Expiration语法
"Expiration":{
"Days": Number,
"CreatedBeforeDate": String,
"ExpiredObjectDeleteMarker": Boolean
}Expiration属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
CreatedBeforeDate | String | 否 | 否 | 指定一个日期,OSS会对最后更新日期早于该日期的数据执行规则。 | 日期必须服从ISO8601的格式,且要求是UTC的零点。例如: |
Days | Number | 否 | 否 | 对象最后修改后,规则将在多少天后生效。 | 以文件最后修改时间为起点开始计算,超过设定天数时即执行规则,则将对象删除。如果设置时间为30天,则最后修改日期为2016年01月01日的对象会在2016年01月31日被后端程序删除。 |
ExpiredObjectDeleteMarker | Boolean | 否 | 否 | 指定是否应自动删除过期的删除标签。 | 有效值如下:
|
AbortMultipartUpload语法
"AbortMultipartUpload": {
"CreatedBeforeDate": String,
"Days": Number
}AbortMultipartUpload属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
CreatedBeforeDate | String | 否 | 否 | 规则在何时之前生效。 | 日期为ISO8601的格式,并且值为UTC的零点。例如: |
Days | Number | 否 | 否 | 对象最后修改后,规则会在多少天后生效。 | 以文件最后修改时间为起点开始计算,超过设定天数时即执行规则,则将对象删除。如果设置时间为30天,则最后修改日期为2016年01月01日的对象会在2016年01月31日被后端程序删除。 |
LoggingConfiguration语法
"LoggingConfiguration": {
"TargetBucket": String,
"TargetPrefix": String
}LoggingConfiguration属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
TargetBucket | String | 否 | 否 | 存放访问日志的存储空间。 | 无 |
TargetPrefix | String | 否 | 否 | 最终被保存的访问日志文件前缀。 | 无 |
WebsiteConfigurationV2语法
"WebsiteConfiguration":{
"RoutingRules": List,
"IndexDocument": Map,
"ErrorDocument": Map
}WebsiteConfigurationV2属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
ErrorDocument | Map | 否 | 否 | 托管的静态错误页。 | 无 |
IndexDocument | Map | 否 | 否 | 托管的静态首页。 | 无 |
RoutingRules | List | 否 | 否 | 路由规则列表。 | 最大长度20。 |
IndexDocument语法
"IndexDocument":{
"Suffix": String,
"Type": String,
"SupportSubDir": String
}IndexDocument属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Suffix | String | 是 | 否 | 默认首页。 | 设置默认首页后,如果您访问以正斜杠(/)结尾的对象,OSS将返回到此默认首页。 |
Type | String | 否 | 否 | 当设置默认首页后,尝试访问以非正斜杠(/)结尾且不存在的对象时的行为如下。 | 此规则仅在SupportSubDir设置为true时生效,并且在RoutingRule之后、ErrorFile之前生效。假设默认首页文件为index.html,当访问的文件路径为bucket.oss-cn-hangzhou.aliyuncs.com/abc,且对象ABC不存在时,针对Type不同值的行为如下:
|
SupportSubDir | String | 否 | 否 | 当访问一个子目录时,是否跳转到该子目录的默认主页。 | 可选范围如下:
|
RoutingRules语法
"RoutingRules":[{
"Redirect": Map,
"Condition": Map,
"RuleNumber": Integer
}]RoutingRules属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Redirect | Map | 是 | 否 | 指定当此规则被匹配时要执行的操作。 | 更多信息,请参见Redirect属性。 |
Condition | Map | 是 | 否 | 匹配条件。 | 此规则仅在满足指定的所有项目时执行。只有当此容器下的每个节点的所有条件都得到满足时,才视为匹配成功。更多信息,请参见Condition属性。 |
RuleNumber | Integer | 是 | 否 | 匹配并执行RoutingRule的序列号,OSS将根据此序列号顺序匹配规则。 | 如果匹配成功,则执行此规则并且不再执行后续规则。 |
Condition语法
"Condition":{
"KeyPrefixEquals": String,
"HttpErrorCodeReturnedEquals": String,
"IncludeHeaders": List,
"KeySuffixEquals": String
}Condition属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
KeyPrefixEquals | String | 否 | 否 | 要匹配的对象名称的前缀。 | 无。 |
HttpErrorCodeReturnedEquals | String | 否 | 否 | 当访问指定的对象时,为了符合此规则,必须返回此状态。 | 当跳转规则镜像回源类型时,此字段必须为404。 |
IncludeHeaders | List | 否 | 否 | 此规则仅当请求中包含指定的头部且其值为指定的值时才会匹配。 | 最多可设置10个这样的条件。更多信息,请参见IncludeHeaders属性。 |
KeySuffixEquals | String | 否 | 否 | 要匹配的对象名称的后缀。 | 无。 |
IncludeHeaders语法
"IncludeHeaders": [
{
"Equals": String,
"Key": String
}
]IncludeHeaders属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Equals | String | 否 | 否 | 头部的值。 | 无 |
Key | String | 是 | 否 | 头标的名称。 | 无 |
RefererConfiguration语法
"RefererConfiguration":{
"AllowEmptyReferer": String,
"RefererList": List
}RefererConfiguration属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
AllowEmptyReferer | Boolean | 否 | 否 | 是否允许referer字段为空的请求访问。 | 取值:
|
RefererList | List | 否 | 否 | 允许referer字段的白名单。 | 无 |
Redirect语法
"Redirect":{
"MirrorFollowRedirect": Boolean,
"MirrorURL": String,
"PassQueryString": Boolean,
"MirrorPassQueryString": Boolean,
"ReplaceKeyWith": String,
"Protocol": String,
"HttpRedirectCode": String,
"ReplaceKeyPrefixWith": String,
"RedirectType": String,
"MirrorHeaders": Map,
"MirrorCheckMd5": Boolean,
"EnableReplacePrefix": Boolean,
"HostName": String
}Redirect属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
MirrorFollowRedirect | Boolean | 否 | 否 | 当镜像回源后得到的结果是3xx状态码时,是否继续跳转到指定的Location以获取数据。 | 此设置仅在RedirectType设置为Mirror时生效。例如,当我们镜像请求回到源站时,源站返回了一个带有Location信息的302状态码。
|
MirrorURL | String | 否 | 否 | 镜像回源站地址。 | 此设置仅在RedirectType配置为Mirror时生效。起源网址必须以http://或https://开头,并以正斜杠(/)结尾,OSS会在此基础上拼接上对象名称来构成返回的URL。例如,若要访问的对象名为myobject,当您将其设置为http://example.com/时,回源URL将会是http://example.com/myobject;如果设置为http://example.com/dir1/,则回源URL将会是http://example.com/dir1/myobject。 |
PassQueryString | Boolean | 否 | 否 | 当执行跳转或回源镜像时,是否携带请求参数。 | 即用户以请求参数a=b&c=d的形式访问OSS,并设置PassQueryString为true时,若规则类型为302跳转,则此请求参数会附加在跳转的Location头部中,例如Location:example.com?a=b&c=d;若规则类型为镜像回源,则此请求参数也会被携带在发起的回源请求中。有效值:true、false(默认)。 |
MirrorPassQueryString | Boolean | 否 | 否 | 与PassQueryString相同,但优先于PassQueryString。此设置仅在RedirectType设置为Mirror时有效。 | 默认值:false。 |
ReplaceKeyWith | String | 否 | 否 | 使用Redirect规则时,对象名称将被ReplaceKeyWith指定的值替换,这使得您可以设置变量。 | 目前支持的变量是{key},它代表请求中的对象名称。假设要访问名为test的对象,如果将ReplaceKeyWith设置为prefix/{key}。那么,后缀将指向http://example.com/prefix/test.suffix的Location头部。 这意味着,当客户端请求原始对象(例如,test)时,服务器会通过Redirect规则将其重定向到一个新位置,该位置的路径由ReplaceKeyWith定义的模式动态生成。在这个例子中,新路径会在“prefix/”后面加上原始对象名(即test),最终重定向的URL变为"http://example.com/prefix/test.suffix"。这里的".suffix"是您提到的后缀部分,按照您的描述它似乎是固定不变的,而"${key}"则成功地被对象名“test”替换。 |
Protocol | String | 否 | 否 | 当执行跳转时的协议规范。 | 该规则仅在RedirectType设置为External或AliCDN的情况下适用。假如您希望访问的文件是“test”,并且想要将其重定向至“example.com”,同时指定协议为https,那么在HTTP响应中的Location头部应设置为"https://example.com/test"。可选的协议值有:http, https。 |
HttpRedirectCode | String | 否 | 否 | 当进行跳转时返回的状态码。 | 仅当RedirectType设置为External或AliCDN时适用。默认值为302。可选值:301、302、307。 |
ReplaceKeyPrefixWith | String | 否 | 否 | 该值将替代重定向中对象名称的前缀。如果前缀为空,则此字符串将在对象名称之前插入。 | 说明 注意:仅允许使用ReplaceKeyWith或ReplaceKeyPrefixWith节点。假设要访问的对象为ABC/test.TXT,如果设置了KeyPrefixEquals为ABC/,并且ReplaceKeyPrefixWith为def/,那么定位(Location)将指向http://example.com/def/test.txt。 |
RedirectType | String | 是 | 否 | 指定跳转的类型。 | 可选范围如下:
|
MirrorHeaders | Map | 否 | 否 | 指定回传到源端时被镜像的头部。 | 此设置仅在RedirectType被设置为Mirror时生效。更多信息,请参见MirrorHeaders属性。 |
MirrorCheckMd5 | Boolean | 否 | 否 | 是否回源检查MD5。 | 此配置仅在RedirectType设置为Mirror时生效。当MirrorCheckMd5设置为true时,如果源站返回的响应中包含Content-Md5头信息,OSS会检查拉取的数据MD5是否与该头信息匹配,如果不匹配,则不会将数据保存到OSS上。默认值:false。 |
EnableReplacePrefix | Boolean | 否 | 否 | 如果将此字段设置为true,对象的前缀将被ReplaceKeyPrefixWith指定的值替换。如果未指定此字段或为空,则意味着对象的前缀将被截断。 | 注意:当ReplaceKeyWith字段不为空时,此字段不能设置为true。默认值:false。 |
HostName | String | 否 | 否 | 跳转的域名。 | 该域名应遵循域名规范。如果要访问的文件名为test,并且协议设置为https,主机名设置为example.com,则Location头部应为https://example.com/test。 |
MirrorHeaders语法
"MirrorHeaders":{
"Remove": List,
"PassAll": Boolean,
"Sets": List,
"Pass": List
}MirrorHeaders属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Remove | List | 否 | 否 | 禁用指定头部向源的透传。 | 这仅在将RedirectType设置为Mirror时有效。每个头部的长度最多为1,024字节,并且字符集包括0-9、a-z、A-Z和破折号(-)。此字段最多可以指定10个。 |
PassAll | Boolean | 否 | 否 | 是否将除以下头部之外的其他头部传递给源。 | 这仅在将RedirectType设置为Mirror时有效。需要排除的头部包括:- content-length, authorization2, authorization, range, date以及其他的通用头部- 以oss-/x-oss-/x-drs-开头的特定头部 默认值为:false 这意味着,默认情况下,这些特定的头部会被传递到镜像源。如果需要修改此行为,可以将此设置调整为true,以不允许这些头部信息通过。 |
Sets | List | 否 | 否 | 设置一个头部到源服务器,当请求被回传给源服务器时,该头部会被设置,无论指定的头部是否包含在请求中。 | 此功能仅在将RedirectType设置为Mirror时生效。此容器最多可以为10组头信息进行这样的设置。更多信息,请参见Sets属性。 |
Pass | List | 否 | 否 | 将指定的头部信息传递给源。 | 此操作仅在将RedirectType设置为镜像(Mirror)时有效。每个头部的最大长度为1,024字节,并且只能包含字符集0-9、a-z、A-Z和破折号(-)。此字段最多可以指定10个头部信息。 |
Sets语法
"Sets": [
{
"Value": String,
"Key": String
}
]Sets属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Value | String | 是 | 否 | 将标头的值设置为最大1024字节,不包括\r\n。 | 此设置仅在RedirectType被设置为镜像(Mirror)时有效。 |
Key | String | 是 | 否 | 将头部键设置为最大1024字节,使用的字符集与Pass相同。 | 此设置仅在RedirectType被设置为Mirror时有效。 |
ErrorDocument语法
"ErrorDocument":{
"Key": String,
"HttpStatus": String
}ErrorDocument属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Key | String | 是 | 否 | 默认错误页面。 | 当指定了一个错误页面时,如果访问的对象不存在,将返回这个错误页面。 |
HttpStatus | String | 否 | 否 | 错误页面的HTTP状态代码。 | 有效值:200、404(默认)。 |
ServerSideEncryptionConfiguration语法
"ServerSideEncryptionConfiguration":{
"KMSMasterKeyID": String,
"SSEAlgorithm": String
}ServerSideEncryptionConfiguration属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
SSEAlgorithm | String | 是 | 否 | 服务端默认加密方式。 | 取值:
|
KMSMasterKeyID | String | 否 | 否 | 密钥ID。 | 只有当SSEAlgorithm值为KMS,且使用指定的密钥加密时,才需指定密钥ID。 |
VersioningConfiguration语法
"VersioningConfiguration":{
"Status": String
}VersioningConfiguration属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Status | String | 是 | 否 | 版本控制状态。 | 取值:
|
返回值
Fn::GetAtt
Name:存储空间名称,全局唯一。
DomainName:通过公网访问存储空间的域名。
InternalDomainName:通过内网访问存储空间的域名。
Arn:阿里云资源名称。
示例
场景 1 :创建OSS存储空间(Bucket)。
ROSTemplateFormatVersion: '2015-09-01'
Description: Creates a simple oss bucket
Parameters:
BucketName:
AssociationProperty: AutoCompleteInput
AssociationPropertyMetadata:
Length: 5
Prefix: simple-oss-bucket
CharacterClasses:
- Class: lowercase
min: 1
Type: String
Label:
en: Bucket Name
Outputs:
BucketDomainName:
Value:
Fn::GetAtt:
- MyBucket
- DomainName
Resources:
MyBucket:
Type: ALIYUN::OSS::Bucket
Properties:
AccessControl: private
BucketName:
Ref: BucketName
Metadata: {}
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": "Creates a simple oss bucket",
"Parameters": {
"BucketName": {
"Type": "String",
"Label": {
"en": "Bucket Name"
},
"AssociationProperty": "AutoCompleteInput",
"AssociationPropertyMetadata": {
"Length": 5 ,
"Prefix": "simple-oss-bucket",
"CharacterClasses": [
{
"Class": "lowercase",
"min": 1
}
]
}
}
},
"Metadata": {
},
"Resources": {
"MyBucket": {
"Type": "ALIYUN::OSS::Bucket",
"Properties": {
"AccessControl": "private",
"BucketName": {
"Ref": "BucketName"
}
}
}
},
"Outputs": {
"BucketDomainName": {
"Value": {
"Fn::GetAtt": [
"MyBucket",
"DomainName"
]
}
}
}
}场景 2 :创建OSS存储桶并启用CDN加速,配置域名解析与优化文件分发策略,支持全球访问与自定义缓存规则。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建OSS存储桶并启用CDN加速,配置域名解析与优化文件分发策略,支持全球访问与自定义缓存规则。
en: Create an OSS bucket and enable CDN acceleration, configure domain name resolution, and optimize file distribution strategies to support global access and custom caching rules.
Parameters:
Scope:
Type: String
Label:
zh-cn: 加速区域
en: Acceleration area
Description:
zh-cn: 选择加速区域。加速区域为仅中国内地和全球时,服务域名必须备案。
en: Select the acceleration area. When the acceleration region is only in mainland China and the world, the service domain name must be filed.
Default: domestic
AllowedValues:
- domestic
- overseas
- global
DomainName:
Type: String
Label:
zh-cn: 加速域名
en: Accelerated domain name
Description:
zh-cn: 加速域名是指接入CDN,用于加速源站的域名。请填写您账号下的域名。
en: Accelerated domain name refers to the domain name of the access CDN used to accelerate the source site. Please fill in the domain name under your account.
BucketName:
Type: String
Label:
en: Bucket Name
zh-cn: 存储空间名称
Description:
en: The name must be 3 to 63 bytes in length, The name must start and end with a lowercase letter or digit.The name can contain only lowercase letters, digits, and hyphens (-).;<br><b>note:<font color='blue'>A bucket name must be globally unique within OSS. Bucket names cannot be changed after the bucket is created.</b></font>
zh-cn: 长度为3~63个字符,必须以小写字母或数字开头和结尾,可以包含小写字母、数字和连字符(-);<br><b>注:<font color='blue'>需要全网唯一性,已经存在的不能在创建。</b></font>
AssociationProperty: AutoCompleteInput
AssociationPropertyMetadata:
Length: 6
Prefix: image-example-
CharacterClasses:
- Class: lowercase
min: 1
Resources:
OssBucket:
Type: ALIYUN::OSS::Bucket
DependsOn: AutoEnableOSS
Properties:
BucketName:
Ref: BucketName
DeletionForce: true
AutoEnableCDN:
Type: ALIYUN::ROS::AutoEnableService
Properties:
ServiceName: CDN
AutoEnableOSS:
Type: ALIYUN::ROS::AutoEnableService
Properties:
ServiceName: OSS
Domain:
Type: ALIYUN::CDN::Domain
Properties:
Sources:
Fn::Sub:
- '[{"content":"${content}", "type":"oss", "priority":"20", "port":80, "weight":"10"}]'
- content:
Fn::GetAtt:
- OssBucket
- DomainName
CdnType: web
Scope:
Ref: Scope
DomainName:
Ref: DomainName
DependsOn: AutoEnableCDN
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
DependsOn: Domain
DomainConfig:
Type: ALIYUN::CDN::DomainConfig
Properties:
FunctionList:
- FunctionArgs:
- ArgName: file_type
ArgValue: jpg,png,jpeg
- ArgName: weight
ArgValue: '99'
- ArgName: ttl
ArgValue: '7776000'
FunctionName: filetype_based_ttl_set
- FunctionArgs:
- ArgName: private_oss_auth
ArgValue: 'on'
- ArgName: perm_private_oss_tbl
ArgValue: ''
FunctionName: l2_oss_key
- FunctionArgs:
- ArgName: filetype
ArgValue: jpeg
- ArgName: webp
ArgValue: 'off'
- ArgName: orient
ArgValue: 'off'
- ArgName: slim
ArgValue: '90'
- ArgName: enable
ArgValue: 'on'
FunctionName: image_transform
DomainNames:
Ref: Domain
DependsOn: DomainRecord
Outputs:
Cname:
Description: CNAME
Value:
Fn::GetAtt:
- Domain
- Cname
DomainName:
Description: DomainName
Value:
Ref: Domain
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- Scope
- DomainName
- BucketName
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "创建OSS存储桶并启用CDN加速,配置域名解析与优化文件分发策略,支持全球访问与自定义缓存规则。",
"en": "Create an OSS bucket and enable CDN acceleration, configure domain name resolution, and optimize file distribution strategies to support global access and custom caching rules."
},
"Parameters": {
"Scope": {
"Type": "String",
"Label": {
"zh-cn": "加速区域",
"en": "Acceleration area"
},
"Description": {
"zh-cn": "选择加速区域。加速区域为仅中国内地和全球时,服务域名必须备案。",
"en": "Select the acceleration area. When the acceleration region is only in mainland China and the world, the service domain name must be filed."
},
"Default": "domestic",
"AllowedValues": [
"domestic",
"overseas",
"global"
]
},
"DomainName": {
"Type": "String",
"Label": {
"zh-cn": "加速域名",
"en": "Accelerated domain name"
},
"Description": {
"zh-cn": "加速域名是指接入CDN,用于加速源站的域名。请填写您账号下的域名。",
"en": "Accelerated domain name refers to the domain name of the access CDN used to accelerate the source site. Please fill in the domain name under your account."
}
},
"BucketName": {
"Type": "String",
"Label": {
"en": "Bucket Name",
"zh-cn": "存储空间名称"
},
"Description": {
"en": "The name must be 3 to 63 bytes in length, The name must start and end with a lowercase letter or digit.The name can contain only lowercase letters, digits, and hyphens (-).;<br><b>note:<font color='blue'>A bucket name must be globally unique within OSS. Bucket names cannot be changed after the bucket is created.</b></font>",
"zh-cn": "长度为3~63个字符,必须以小写字母或数字开头和结尾,可以包含小写字母、数字和连字符(-);<br><b>注:<font color='blue'>需要全网唯一性,已经存在的不能在创建。</b></font>"
},
"AssociationProperty": "AutoCompleteInput",
"AssociationPropertyMetadata": {
"Length": 6,
"Prefix": "image-example-",
"CharacterClasses": [
{
"Class": "lowercase",
"min": 1
}
]
}
}
},
"Resources": {
"OssBucket": {
"Type": "ALIYUN::OSS::Bucket",
"DependsOn": "AutoEnableOSS",
"Properties": {
"BucketName": {
"Ref": "BucketName"
},
"DeletionForce": true
}
},
"AutoEnableCDN": {
"Type": "ALIYUN::ROS::AutoEnableService",
"Properties": {
"ServiceName": "CDN"
}
},
"AutoEnableOSS": {
"Type": "ALIYUN::ROS::AutoEnableService",
"Properties": {
"ServiceName": "OSS"
}
},
"Domain": {
"Type": "ALIYUN::CDN::Domain",
"Properties": {
"Sources": {
"Fn::Sub": [
"[{\"content\":\"${content}\", \"type\":\"oss\", \"priority\":\"20\", \"port\":80, \"weight\":\"10\"}]",
{
"content": {
"Fn::GetAtt": [
"OssBucket",
"DomainName"
]
}
}
]
},
"CdnType": "web",
"Scope": {
"Ref": "Scope"
},
"DomainName": {
"Ref": "DomainName"
}
},
"DependsOn": "AutoEnableCDN"
},
"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"
}
]
}
]
}
]
}
},
"DependsOn": "Domain"
},
"DomainConfig": {
"Type": "ALIYUN::CDN::DomainConfig",
"Properties": {
"FunctionList": [
{
"FunctionArgs": [
{
"ArgName": "file_type",
"ArgValue": "jpg,png,jpeg"
},
{
"ArgName": "weight",
"ArgValue": "99"
},
{
"ArgName": "ttl",
"ArgValue": "7776000"
}
],
"FunctionName": "filetype_based_ttl_set"
},
{
"FunctionArgs": [
{
"ArgName": "private_oss_auth",
"ArgValue": "on"
},
{
"ArgName": "perm_private_oss_tbl",
"ArgValue": ""
}
],
"FunctionName": "l2_oss_key"
},
{
"FunctionArgs": [
{
"ArgName": "filetype",
"ArgValue": "jpeg"
},
{
"ArgName": "webp",
"ArgValue": "off"
},
{
"ArgName": "orient",
"ArgValue": "off"
},
{
"ArgName": "slim",
"ArgValue": "90"
},
{
"ArgName": "enable",
"ArgValue": "on"
}
],
"FunctionName": "image_transform"
}
],
"DomainNames": {
"Ref": "Domain"
}
},
"DependsOn": "DomainRecord"
}
},
"Outputs": {
"Cname": {
"Description": "CNAME",
"Value": {
"Fn::GetAtt": [
"Domain",
"Cname"
]
}
},
"DomainName": {
"Description": "DomainName",
"Value": {
"Ref": "Domain"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"Scope",
"DomainName",
"BucketName"
]
}
]
}
}
}场景 3 :创建ECS实例、OSS存储桶,安装应用,实现文本绘图与人像美化服务。
ROSTemplateFormatVersion: '2015-09-01'
Mappings: {}
Parameters:
DashScopeApiKey:
NoEcho: true
Label:
zh-cn: DashScope API-KEY
en: DashScope API-KEY
Type: String
Description:
zh-cn: 开通灵积模型服务,并获得 API-KEY。请参考: <a href="https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key" target="_blank">开通DashScope并创建API-KEY</a>。
en: 'Activate DashScope and obtain the API-KEY. Please refer to: <a href="https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key" target="_blank">Activate DashScope and create API-KEY</a>.'
AssociationProperty: ALIYUN::DashScope::ApiKey
CommonName:
Default: wanxiang
Type: String
InstancePassword:
Description:
zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
Default: Null
Type: String
Label:
zh-cn: 实例密码
en: Instance Password
NoEcho: true
AssociationProperty: ALIYUN::ECS::Instance::Password
ConstraintDescription:
zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)
en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
ZoneId:
AssociationPropertyMetadata:
AutoSelectFirst: true
Default: Null
Required: true
Label:
zh-cn: 可用区
en: Availability Zone
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
Type: String
BucketName:
AssociationPropertyMetadata:
Length: 5
Prefix: drawing-with-tongyi-wanxiang-
CharacterClasses:
- Class: lowercase
min: 1
Description:
zh-cn: 3到63个字符,不以连字符(-)开头和结尾,可以包含小写字母、数字和连字符(-);<br>备注:<font color='blue'><b>需要保证整个网络的唯一性,已经存在的无法创建</b></font>
en: '3 to 63 characters, not beginning and ending with a hyphen (-), can contain lowercase letters, Numbers and hyphens (-);<br>Note: <font color=''blue''><b>need whole network uniqueness, already existing can not be created.</b></font>'
MinLength: 3
Label:
zh-cn: 存储空间名称
en: Bucket Name
AllowedPattern: ^[a-z0-9]+[a-z0-9\-]*[a-z0-9]+$
Type: String
MaxLength: 63
AssociationProperty: AutoCompleteInput
ConstraintDescription:
zh-cn: 3 到 63 个字符,不以连字符 (-) 开头和结尾,可以包含小写字母、数字和连字符 (-)
en: 3 to 63 characters, not beginning and ending with a hyphen (-), can contain lowercase letters, Numbers and hyphens (-)
InstanceType:
AssociationPropertyMetadata:
SystemDiskCategory: cloud_essd
InstanceChargeType: PostPaid
ZoneId: ${ZoneId}
Default: Null
Required: true
Label:
zh-cn: 实例类型
en: Instance Type
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
Type: String
Outputs:
EcsLoginAddress:
Description:
zh-cn: ECS登录地址。
en: Ecs login address.
Value:
Fn::Sub: https://ecs-workbench.aliyun.com/?from=EcsConsole&instanceType=ecs®ionId=${ALIYUN::Region}&instanceId=${EcsInstance}
ExperienceAddress:
Description:
zh-cn: 体验地址。
en: Experience address.
Value:
Fn::Sub:
- http://${PublicIp}/wanx-demo
- PublicIp:
Fn::Select:
- 0
- Fn::GetAtt:
- EcsInstance
- PublicIps
Description:
zh-cn: 创建VPC、ECS实例、OSS存储桶,配置安全组和RAM访问权限,安装Java与应用,实现文本绘图与人像美化服务。
en: Create a Virtual Private Cloud (VPC), Elastic Compute Service (ECS) instances, Object Storage Service (OSS) buckets, configure Security Groups and Resource Access Management (RAM) permissions, install Java and applications, and implement text drawing and portrait beautification services.
Conditions: {}
Resources:
CustomPolicy:
Type: ALIYUN::RAM::ManagedPolicy
Properties:
PolicyName:
Fn::Sub: create_by_solution-${ALIYUN::StackId}
PolicyDocument:
Version: '1'
Statement:
- Action:
- oss:GetObject
- oss:PutObject
Resource:
- Fn::Sub: acs:oss:oss-${ALIYUN::Region}:${ALIYUN::TenantId}:${BucketName}/*
Effect: Allow
InstallApp:
Type: ALIYUN::ECS::RunCommand
Properties:
CommandContent:
Fn::Sub: |-
#!/bin/bash
cat << EOF >> ~/.bash_profile
export DASHSCOPE_API_KEY=${DashScopeApiKey}
export OSS_ACCESS_KEY_ID=${AccessKey.AccessKeyId}
export OSS_ACCESS_KEY_SECRET=${AccessKey.AccessKeySecret}
export WANX_DEMO_OSS_BUCKET=${BucketName}
export WANX_DEMO_OSS_ENDPOINT=https://oss-${ALIYUN::Region}.aliyuncs.com
EOF
source ~/.bash_profile
wget https://help-static-aliyun-doc.aliyuncs.com/demos/wanx-demo-0.0.1-SNAPSHOT.jar
nohup java -jar wanx-demo-0.0.1-SNAPSHOT.jar > wanx-demo.log 2>&1 &
Type: RunShellScript
Sync: true
InstanceIds:
- Ref: EcsInstance
Timeout: 3600
DependsOn:
- ModuleInstallJava.Install
AccessKey:
Type: ALIYUN::RAM::AccessKey
Properties:
UserName:
Ref: User
Bucket:
Type: ALIYUN::OSS::Bucket
Properties:
BucketName:
Ref: BucketName
DeletionForce: true
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
SecurityGroupIngress:
- PortRange: 80/80
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
VpcId:
Ref: Vpc
SecurityGroupName:
Fn::Sub: ${CommonName}-sg
ModuleInstallJava.Install:
Type: ALIYUN::OOS::Execution
Properties:
SafetyCheck: Skip
Parameters:
action: install
packageName: ACS-Extension-java-1853370294850618
regionId:
Ref: ALIYUN::Region
targets:
ResourceIds:
- Ref: EcsInstance
RegionId:
Ref: ALIYUN::Region
Type: ResourceIds
parameters: Null
TemplateName: ACS-ECS-BulkyConfigureOOSPackageWithTemporaryURL
Metadata:
ALIYUN::ROS::Module:
LogicalIdHierarchy: ModuleInstallJava
TypeHierarchy: MODULE::ACS::OOS::Extension
User:
Type: ALIYUN::RAM::User
Properties:
UserName:
Fn::Sub: create_by_solution-${ALIYUN::StackId}
PolicyAttachments:
Custom:
- Ref: CustomPolicy
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
VpcName:
Fn::Sub: ${CommonName}-vpc
CidrBlock: 192.168.0.0/16
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
VSwitchName:
Fn::Sub: ${CommonName}-vsw
VpcId:
Ref: Vpc
CidrBlock: 192.168.0.0/24
ZoneId:
Ref: ZoneId
EcsInstance:
Type: ALIYUN::ECS::InstanceGroup
Properties:
SystemDiskCategory: cloud_essd
VpcId:
Ref: Vpc
SecurityGroupId:
Ref: SecurityGroup
ImageId: aliyun_3_9_x64_20G_alibase_
InternetMaxBandwidthOut: 5
VSwitchId:
Ref: VSwitch
Password:
Ref: InstancePassword
InstanceName:
Fn::Sub: ${CommonName}-ecs
InstanceType:
Ref: InstanceType
ZoneId:
Ref: ZoneId
MaxAmount: 1
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- DashScopeApiKey
- BucketName
- ZoneId
- InstanceType
- InstancePassword
Hidden:
- CommonName
{
"ROSTemplateFormatVersion": "2015-09-01",
"Mappings": {},
"Parameters": {
"DashScopeApiKey": {
"NoEcho": true,
"Label": {
"zh-cn": "DashScope API-KEY",
"en": "DashScope API-KEY"
},
"Type": "String",
"Description": {
"zh-cn": "开通灵积模型服务,并获得 API-KEY。请参考: <a href=\"https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key\" target=\"_blank\">开通DashScope并创建API-KEY</a>。",
"en": "Activate DashScope and obtain the API-KEY. Please refer to: <a href=\"https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key\" target=\"_blank\">Activate DashScope and create API-KEY</a>."
},
"AssociationProperty": "ALIYUN::DashScope::ApiKey"
},
"CommonName": {
"Default": "wanxiang",
"Type": "String"
},
"InstancePassword": {
"Description": {
"zh-cn": "服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)",
"en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)"
},
"Default": null,
"Type": "String",
"Label": {
"zh-cn": "实例密码",
"en": "Instance Password"
},
"NoEcho": true,
"AssociationProperty": "ALIYUN::ECS::Instance::Password",
"ConstraintDescription": {
"zh-cn": "长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)",
"en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)"
}
},
"ZoneId": {
"AssociationPropertyMetadata": {
"AutoSelectFirst": true
},
"Default": null,
"Required": true,
"Label": {
"zh-cn": "可用区",
"en": "Availability Zone"
},
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"Type": "String"
},
"BucketName": {
"AssociationPropertyMetadata": {
"Length": 5,
"Prefix": "drawing-with-tongyi-wanxiang-",
"CharacterClasses": [
{
"Class": "lowercase",
"min": 1
}
]
},
"Description": {
"zh-cn": "3到63个字符,不以连字符(-)开头和结尾,可以包含小写字母、数字和连字符(-);<br>备注:<font color='blue'><b>需要保证整个网络的唯一性,已经存在的无法创建</b></font>",
"en": "3 to 63 characters, not beginning and ending with a hyphen (-), can contain lowercase letters, Numbers and hyphens (-);<br>Note: <font color='blue'><b>need whole network uniqueness, already existing can not be created.</b></font>"
},
"MinLength": 3,
"Label": {
"zh-cn": "存储空间名称",
"en": "Bucket Name"
},
"AllowedPattern": "^[a-z0-9]+[a-z0-9\\-]*[a-z0-9]+$",
"Type": "String",
"MaxLength": 63,
"AssociationProperty": "AutoCompleteInput",
"ConstraintDescription": {
"zh-cn": "3 到 63 个字符,不以连字符 (-) 开头和结尾,可以包含小写字母、数字和连字符 (-)",
"en": "3 to 63 characters, not beginning and ending with a hyphen (-), can contain lowercase letters, Numbers and hyphens (-)"
}
},
"InstanceType": {
"AssociationPropertyMetadata": {
"SystemDiskCategory": "cloud_essd",
"InstanceChargeType": "PostPaid",
"ZoneId": "${ZoneId}"
},
"Default": null,
"Required": true,
"Label": {
"zh-cn": "实例类型",
"en": "Instance Type"
},
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"Type": "String"
}
},
"Outputs": {
"EcsLoginAddress": {
"Description": {
"zh-cn": "ECS登录地址。",
"en": "Ecs login address."
},
"Value": {
"Fn::Sub": "https://ecs-workbench.aliyun.com/?from=EcsConsole&instanceType=ecs®ionId=${ALIYUN::Region}&instanceId=${EcsInstance}"
}
},
"ExperienceAddress": {
"Description": {
"zh-cn": "体验地址。",
"en": "Experience address."
},
"Value": {
"Fn::Sub": [
"http://${PublicIp}/wanx-demo",
{
"PublicIp": {
"Fn::Select": [
0,
{
"Fn::GetAtt": [
"EcsInstance",
"PublicIps"
]
}
]
}
}
]
}
}
},
"Description": {
"zh-cn": "创建VPC、ECS实例、OSS存储桶,配置安全组和RAM访问权限,安装Java与应用,实现文本绘图与人像美化服务。",
"en": "Create a Virtual Private Cloud (VPC), Elastic Compute Service (ECS) instances, Object Storage Service (OSS) buckets, configure Security Groups and Resource Access Management (RAM) permissions, install Java and applications, and implement text drawing and portrait beautification services."
},
"Conditions": {},
"Resources": {
"CustomPolicy": {
"Type": "ALIYUN::RAM::ManagedPolicy",
"Properties": {
"PolicyName": {
"Fn::Sub": "create_by_solution-${ALIYUN::StackId}"
},
"PolicyDocument": {
"Version": "1",
"Statement": [
{
"Action": [
"oss:GetObject",
"oss:PutObject"
],
"Resource": [
{
"Fn::Sub": "acs:oss:oss-${ALIYUN::Region}:${ALIYUN::TenantId}:${BucketName}/*"
}
],
"Effect": "Allow"
}
]
}
}
},
"InstallApp": {
"Type": "ALIYUN::ECS::RunCommand",
"Properties": {
"CommandContent": {
"Fn::Sub": "#!/bin/bash\n\ncat << EOF >> ~/.bash_profile\nexport DASHSCOPE_API_KEY=${DashScopeApiKey}\nexport OSS_ACCESS_KEY_ID=${AccessKey.AccessKeyId}\nexport OSS_ACCESS_KEY_SECRET=${AccessKey.AccessKeySecret}\nexport WANX_DEMO_OSS_BUCKET=${BucketName}\nexport WANX_DEMO_OSS_ENDPOINT=https://oss-${ALIYUN::Region}.aliyuncs.com\nEOF\n\nsource ~/.bash_profile \nwget https://help-static-aliyun-doc.aliyuncs.com/demos/wanx-demo-0.0.1-SNAPSHOT.jar\nnohup java -jar wanx-demo-0.0.1-SNAPSHOT.jar > wanx-demo.log 2>&1 &"
},
"Type": "RunShellScript",
"Sync": true,
"InstanceIds": [
{
"Ref": "EcsInstance"
}
],
"Timeout": 3600
},
"DependsOn": [
"ModuleInstallJava.Install"
]
},
"AccessKey": {
"Type": "ALIYUN::RAM::AccessKey",
"Properties": {
"UserName": {
"Ref": "User"
}
}
},
"Bucket": {
"Type": "ALIYUN::OSS::Bucket",
"Properties": {
"BucketName": {
"Ref": "BucketName"
},
"DeletionForce": true
}
},
"SecurityGroup": {
"Type": "ALIYUN::ECS::SecurityGroup",
"Properties": {
"SecurityGroupIngress": [
{
"PortRange": "80/80",
"SourceCidrIp": "0.0.0.0/0",
"IpProtocol": "tcp"
}
],
"VpcId": {
"Ref": "Vpc"
},
"SecurityGroupName": {
"Fn::Sub": "${CommonName}-sg"
}
}
},
"ModuleInstallJava.Install": {
"Type": "ALIYUN::OOS::Execution",
"Properties": {
"SafetyCheck": "Skip",
"Parameters": {
"action": "install",
"packageName": "ACS-Extension-java-1853370294850618",
"regionId": {
"Ref": "ALIYUN::Region"
},
"targets": {
"ResourceIds": [
{
"Ref": "EcsInstance"
}
],
"RegionId": {
"Ref": "ALIYUN::Region"
},
"Type": "ResourceIds"
},
"parameters": null
},
"TemplateName": "ACS-ECS-BulkyConfigureOOSPackageWithTemporaryURL"
},
"Metadata": {
"ALIYUN::ROS::Module": {
"LogicalIdHierarchy": "ModuleInstallJava",
"TypeHierarchy": "MODULE::ACS::OOS::Extension"
}
}
},
"User": {
"Type": "ALIYUN::RAM::User",
"Properties": {
"UserName": {
"Fn::Sub": "create_by_solution-${ALIYUN::StackId}"
},
"PolicyAttachments": {
"Custom": [
{
"Ref": "CustomPolicy"
}
]
}
}
},
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"VpcName": {
"Fn::Sub": "${CommonName}-vpc"
},
"CidrBlock": "192.168.0.0/16"
}
},
"VSwitch": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VSwitchName": {
"Fn::Sub": "${CommonName}-vsw"
},
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "192.168.0.0/24",
"ZoneId": {
"Ref": "ZoneId"
}
}
},
"EcsInstance": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"SystemDiskCategory": "cloud_essd",
"VpcId": {
"Ref": "Vpc"
},
"SecurityGroupId": {
"Ref": "SecurityGroup"
},
"ImageId": "aliyun_3_9_x64_20G_alibase_",
"InternetMaxBandwidthOut": 5,
"VSwitchId": {
"Ref": "VSwitch"
},
"Password": {
"Ref": "InstancePassword"
},
"InstanceName": {
"Fn::Sub": "${CommonName}-ecs"
},
"InstanceType": {
"Ref": "InstanceType"
},
"ZoneId": {
"Ref": "ZoneId"
},
"MaxAmount": 1
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"DashScopeApiKey",
"BucketName",
"ZoneId",
"InstanceType",
"InstancePassword"
]
}
],
"Hidden": [
"CommonName"
]
}
}
}