ALIYUN::ROS::CustomResource類型用於建立自訂資源。
在ROS模板中,您可以使用ALIYUN::ROS::CustomResource或Custom::String資源類型來指定自訂資源。
自訂資源為您提供了一種在ROS模板中編寫自訂配置邏輯並使ROS在資源棧操作(如建立、更新或刪除資源棧)期間運行該邏輯的方式。有關更多資訊,請參見自訂資源概覽。
自訂資源必須將響應發送到預簽名的響應URL。如果不能向ROS發送響應,阿里雲ROS不會收到響應,資源棧操作就會失敗。ResponseURL提供了公網響應的能力,InnerResponseURL提供了阿里雲內網響應的能力。
文法
{
"Type": "ALIYUN::ROS::CustomResource",
"Properties": {
"ServiceToken": String,
"Timeout": Number,
"Parameters": Map
}
}屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
ServiceToken | String | 是 | 否 | 服務令牌,由custom service provider向template developer提供。 目前支援FC(Function Compute)Function、SMQ( Simple Message Queue (formerly MNS) )Topic、SMQQueue、HTTP&HTTPS。 最大長度512。 | 取值:
樣本:
|
Timeout | Number | 是 | 是 | 等待custom service provider響應的逾時時間,單位:秒。 |
|
Parameters | Map | 否 | 是 | 要傳遞給custom service provider的參數。按照custom service provider提供的規範填寫。 | 無。 |
傳回值
Fn::GetAtt
Outputs:從custom service provider接收的資料,Map對象。
*:*的具體值為Outputs中的key。
樣本
ROSTemplateFormatVersion: '2015-09-01'
Resources:
CustomResource:
Type: ALIYUN::ROS::CustomResource
Properties:
ServiceToken: acs:fc:cn-hangzhou:123456789:services/test-service/functions/test-function
Parameters:
Key1: Value1
Key2: Value2
Timeout: 60
Parameters:
Parameters:
Type: Json
Description: Parameters to be passed to service provider.
Outputs:
Outputs:
Description: Output data received from service provider.
Value:
Fn::GetAtt:
- CustomResource
- Outputs{
"ROSTemplateFormatVersion": "2015-09-01",
"Resources": {
"CustomResource": {
"Type": "ALIYUN::ROS::CustomResource",
"Properties": {
"ServiceToken": "acs:fc:cn-hangzhou:123456789:services/test-service/functions/test-function",
"Parameters": {
"Key1": "Value1",
"Key2": "Value2"
},
"Timeout": 60
}
}
},
"Parameters": {
"Parameters": {
"Type": "Json",
"Description": "Parameters to be passed to service provider."
}
},
"Outputs": {
"Outputs": {
"Description": "Output data received from service provider.",
"Value": {
"Fn::GetAtt": [
"CustomResource",
"Outputs"
]
}
}
}
}備忘
指定自訂資源類型名稱
對於自訂資源,您可以指定ALIYUN::ROS::CustomResource作為資源類型,也可以指定自己的資源類型名稱。例如:您可以使用ALIYUN::ROS::CustomResource,而不使用Custom::MyCustomResourceTypeName。
自訂資源類型名稱可包含英文字母、數字和特殊字元:
_@-。您可指定最大長度為68個字元的自訂資源類型名稱。在更新期間,不能更改類型。使用自己的資源類型名稱有助於快速區分堆棧中自訂資源的類型。例如,如果您有執行兩種不同ping測試的兩個自訂資源,則可以將其類型命名為Custom::PingTester(而不使用 ALIYUN::ROS::CustomResource)以便方便地識別為ping測試器。
在更新期間替換自訂資源
ROS不允許在更新期間替換其PhysicalResourceId。
檢索傳回值
對於自訂資源,傳回值是由自訂資源供應商定義的,並且可通過調用Fn::GetAtt在供應商定義的屬性中進行檢索。