全部產品
Search
文件中心

Resource Orchestration Service:ALIYUN::OSS::Bucket

更新時間:Feb 06, 2026

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

存取權限。

取值:

  • private(預設值):私人。

  • public-read:公用讀取。

  • public-read-write:公用讀寫。

CORSConfiguration

Map

跨域訪問配置。

更多資訊,請參見CORSConfiguration屬性

DeletionForce

Boolean

是否強制移除OSS中的檔案。

取值:

  • true:強制移除。

  • false(預設值):不強制移除。

EnableOssHdfsService

Boolean

是否開啟OSS-HDFS服務。

取值:

  • true:開啟OSS-HDFS服務。

    說明

    一旦啟用,它不能再被禁用。

  • false:不開啟OSS-HDFS服務。 

BlockPublicAccess

Boolean

是否為指定Bucket開啟阻止公用訪問。

取值:

  • true:開啟阻止公用訪問。

  • false(預設值):關閉阻止公用訪問。

LifecycleConfiguration

Map

檔案生命週期配置。

更多資訊,請參見LifecycleConfiguration屬性

LoggingConfiguration

Map

日誌儲存配置。

更多資訊,請參見LoggingConfiguration屬性

Policy

Map

儲存空間策略。

更多資訊,請參見Bucket Policy常見樣本

RedundancyType

String

Bucket的資料容災類型。

取值:

  • LRS(預設) :本地冗餘LRS,將您的資料冗餘儲存在同一個可用性區域的不同存放裝置上,可支援兩個存放裝置並發損壞時,仍鑑效組資料不丟失,可正常訪問。

  • ZRS:同城冗餘ZRS,採用多可用性區域(AZ)機制,將您的資料冗餘儲存在同一地區(Region)的3個可用性區域。可支援單個可用性區域(機房)整體故障時(例如斷電、火災等),仍然能夠保障資料的正常訪問。

RefererConfiguration

Map

防盜鏈配置。

更多資訊,請參見RefererConfiguration屬性

ResourceGroupId

String

資源群組ID。

ServerSideEncryptionConfiguration

Map

服務端加密規則配置。

更多資訊,請參見ServerSideEncryptionConfiguration屬性

StorageClass

String

儲存空間類型。

取值:

  • Standard(預設值):標準儲存。

  • IA:低頻訪問。

  • Archive:Archive Storage。

Tags

Map

儲存空間標籤。Key-Value形式的索引值對。

最多設定20個標籤。

Key長度為1~64個字元,不能以http://https://Aliyun開頭。

Value長度為0~128個字元,必須為UTF-8編碼。

VersioningConfiguration

Map

儲存版本控制狀態的容器。

更多資訊,請參見VersioningConfiguration屬性

WebsiteConfigurationV2

Map

網站配置。

更多資訊,請參見WebsiteConfigurationV2屬性

CORSConfiguration文法

"CORSConfiguration": {
  "CORSRule": List,
  "ResponseVary": Boolean
}

CORSConfiguration屬性

屬性名稱

類型

必須

允許更新

描述

約束

CORSRule

List

跨域訪問規則。

更多資訊,請參見CORSRule屬性

ResponseVary

Boolean

是否返回Vary: Origin頭部。

其取值範圍如下:

  • true:無論是否發送了跨域請求,或者跨域請求是否成功,都返回Vary: Origin頭部。

  • false(預設):在任何情況下都不返回Vary: Origin頭部。

說明

注意:此欄位不能單獨配置;必須至少配置一條跨域規則才會生效。

CORSRule文法

"CORSRule": [
  {
    "MaxAgeSeconds": Number,
    "AllowedMethod": List,
    "ExposeHeader": List,
    "AllowedOrigin": List,
    "AllowedHeader": List
  }
]

CORSRule屬性

屬性名稱

類型

必須

允許更新

描述

約束

AllowedHeader

List

允許的跨域請求Header。

取值:

  • *

  • Cache-Control

  • Content-Language

  • Content-Type

  • Expires

  • Last-Modified

  • Pragma

AllowedMethod

List

允許的跨域請求的方法。

取值:

  • *

  • GET

  • PUT

  • POST

  • DELETE

  • HEAD

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

啟用或停用規則。

取值:

  • Enabled:啟用規則。

  • Disabled:停用規則。

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)。
樣本值:2002-10-11T00:00:00.000Z

Days

Integer

指定對象最後一次更新後多少天生效生命週期規則。

取值範圍:正整數(例如:30、90、180 等)。

IsAccessTime

Boolean

指定生命週期規則是否基於對象的最後訪問時間來應用。

  • true:表示規則根據對象的最後訪問時間生效。

  • false:表示規則不基於最後訪問時間,而是基於其他條件(如建立時間或修改時間)。

ReturnToStdWhenVisit

Boolean

指定是否在非標準類型對象被訪問後,將其儲存類別恢複為標準類型。

此選項僅在將 IsAccessTime 元素設定為 true 時生效。

AllowSmallFile

Boolean

指定是否根據對象的最後訪問時間。

將其儲存類別更改為 IA、歸檔(Archive)或冷歸檔(Cold Archive),前提是對象大小小於 64 KB。

StorageClass

String

對象被更改後的儲存類別。

取值:

  • IA

  • Archive

  • ColdArchive

  • DeepColdArchive

Filter文法

"Filter":{
  "Not": Map
}

Filter屬性

屬性名稱

類型

必須

允許更新

描述

約束

Not

Map

排除規則

更多資訊,請參見Not屬性

Not文法

"Not":{
  "Tag": List,
  "Prefix": String
}

Not屬性

屬性名稱

類型

必須

允許更新

描述

約束

Tag

List

排除規則的標籤。

這條排除規則最多適用於一個對象標籤。

Prefix

String

規則首碼。

此排除規則所適用的對象首碼條件如下:

  • 如果在規則(Rule)節點下配置了首碼(Prefix),那麼在非(Not)節點下的首碼必須以規則節點下配置的首碼為開頭。例如,如果在規則節點下配置的首碼是dir,則非節點下配置的首碼必須以dir開頭,如dir1dir2等。

  • 如果在非(Not)節點下沒有配置標籤(Tag),那麼非節點下配置的首碼不能與規則節點下配置的首碼相同。

簡而言之,這條規則說明了在設定排除規則時,如果上級規則定義了一個首碼,那麼下屬的非規則內的首碼必須是上級首碼的子集或具體化,且不能完全相同(除非使用了標籤配置)。這樣設計是為了實現更細緻和靈活的檔案或對象篩選邏輯,特別是在雲端儲存、資料備份或內容過濾等情境中。

Expiration文法

"Expiration":{
  "Days": Number,
  "CreatedBeforeDate": String,
  "ExpiredObjectDeleteMarker": Boolean
}

Expiration屬性

屬性名稱

類型

必須

允許更新

描述

約束

CreatedBeforeDate

String

指定一個日期,OSS會對最後更新日期早於該日期的資料執行規則。

日期必須服從ISO8601的格式,且要求是UTC的零點。例如:2002-10-11T00:00:00.000Z

Days

Number

對象最後修改後,規則將在多少天后生效。

以檔案最後修改時間為起點開始計算,超過設定天數時即執行規則,則將對象刪除。如果設定時間為30天,則最後修改日期為2016年01月01日的對象會在2016年01月31日被後端程式刪除。

ExpiredObjectDeleteMarker

Boolean

指定是否應自動刪除到期的刪除標籤。

有效值如下:

  • true:這意味著到期刪除標記將自動被移除。當設定為true時,指定Days或CreatedBeforeDate是不被支援的。

  • false:這表示到期刪除標記不會被自動移除。當設為false時,必須指定Days或CreatedBeforeDate中的一個。

AbortMultipartUpload文法

"AbortMultipartUpload": {
  "CreatedBeforeDate": String,
  "Days": Number
}

AbortMultipartUpload屬性

屬性名稱

類型

必須

允許更新

描述

約束

CreatedBeforeDate

String

規則在何時之前生效。

日期為ISO8601的格式,並且值為UTC的零點。例如:2002-10-11T00:00:00.000Z

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不同值的行為如下:

  • 0(預設):檢查abc/index.html是否存在(對象加上正斜杠(/)再加上首頁名稱),如果存在,則返回302重新導向狀態代碼,並在Location頭部中設定URL代碼為/abc/(正斜杠(/)加上對象名再加正斜杠(/))。如果不存在,則返回404錯誤,並繼續檢查ErrorFile。

  • 1:直接返回404錯誤,錯誤類型為NoSuchKey,然後繼續檢查ErrorFile。

  • 2:檢查abc/index.html是否存在,如果存在則直接返回該對象的內容。如果不存在,則返回404錯誤,並繼續檢查ErrorFile。

SupportSubDir

String

當訪問一個子目錄時,是否跳轉到該子目錄的預設首頁。

可選範圍如下:

  • true:跳轉到子目錄下的預設首頁。

  • false(預設):不跳轉到子目錄下的預設首頁,而是前往根目錄下的預設首頁。假設預設首頁為index.html,如果訪問bucket.oss-cn-hangzhou.aliyuncs.com/subdir/時,將SupportSubDir設定為false,則會重新導向到bucket.oss-cn-hangzhou.aliyuncs.com/index.html;如果將SupportSubDir設定為true,則會重新導向到bucket.oss-cn-hangzhou.aliyuncs.com/subdir/index.html。

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欄位為空白的請求訪問。

取值:

  • true(預設值):允許。

  • false:不允許。

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狀態代碼。

  • 如果設定為true,OSS將繼續請求該Location指向的地址。這個過程最多可以跳轉10次,超過10次後,鏡像回源將失敗並返回錯誤。

  • 如果設定為false,OSS將直接返回302狀態代碼,並將Location資訊透傳給用戶端,由用戶端決定是否繼續跳轉。

    預設值為:true。

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

指定跳轉的類型。

可選範圍如下:

  • 鏡像(Mirror):回源鏡像,即反射回來源站點。

  • 外部(External):外部分支,即OSS會返回一個3xx狀態代碼的請求,指示將分支指向另一個地址。

  • 阿里雲CDN(AliCDN):阿里雲CDN跳轉,主要用於阿里雲的內容分發網路。與“外部”不同的是,OSS會添加一個額外的頭部資訊。阿里雲CDN識別到這個頭部後,會主動跳轉到指定的地址,並將擷取的資料返回給使用者,而不是向使用者返回3xx的跳轉請求。

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

服務端預設加密方式。

取值:

  • KMS

  • AES256

KMSMasterKeyID

String

密鑰ID。

只有當SSEAlgorithm值為KMS,且使用指定的祕密金鑰加密時,才需指定密鑰ID。

VersioningConfiguration文法

"VersioningConfiguration":{
  "Status": String
}

VersioningConfiguration屬性

屬性名稱

類型

必須

允許更新

描述

約束

Status

String

版本控制狀態。

取值:

  • Enabled:開啟版本控制狀態

  • Suspended:暫停版本控制狀態

傳回值

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://www.alibabacloud.com/help/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://www.alibabacloud.com/help/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&regionId=${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://www.alibabacloud.com/help/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://www.alibabacloud.com/help/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&regionId=${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"
      ]
    }
  }
}

更多樣本,請參考包含此資源的公用模板。