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、MNS(消息服务)Topic、MNS(消息服务)Queue、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。
示例
JSON
格式
{
"ROSTemplateFormatVersion": "2015-09-01",
"Resources": {
"CustomResource": {
"Type": "ALIYUN::ROS::CustomResource",
"Properties": {
"ServiceToken": {
"Ref": "ServiceToken"
},
"Parameters": {
"Ref": "Parameters"
},
"Timeout": {
"Ref": "Timeout"
}
}
}
},
"Parameters": {
"ServiceToken": {
"Type": "String",
"Description": "The service token that was given to the template developer by the service provider to access the service.Allowed values:- Function Compute: acs:fc:<region_id>:<account_id>:services/<service_name>/functions/<function_name>- MNS Queue: acs:mns:<region_id>:<account_id>:queues/<queue_name>- MNS Topic: acs:mns:<region_id>:<account_id>:topics/<topic_name>- HTTP&HTTPS: web[options]:<url> Two options are supported: - sync: sync HTTP&HTTPS request. - idempotent: indicates that the Create request is idempotent. Update and Delete requests should be always idempotent.Examples: - acs:fc:cn-hangzhou:123456789:services/test-service/functions/test-function - acs:mns:cn-hangzhou:123456789:queues/test-queue - acs:mns:cn-hangzhou:123456789:topics/test-topic - web:https://abc.com - web[sync]:http://abc.com - web[sync,idempotent]:https://abc.com",
"MaxLength": 512
},
"Parameters": {
"Type": "Json",
"Description": "Parameters to be passed to service provider."
},
"Timeout": {
"Default": 60,
"Type": "Number",
"Description": "Timeout seconds before service provider responses.It takes effects only if the type of ServiceToken is Function Compute, MNS Queue, MNS Topic or async HTTP&HTTPS request.Timeout seconds are always 10 for sync HTTP&HTTPS request.",
"MaxValue": 43200,
"MinValue": 1
}
},
"Outputs": {
"Outputs": {
"Description": "Output data received from service provider.",
"Value": {
"Fn::GetAtt": [
"CustomResource",
"Outputs"
]
}
}
}
}
YAML
格式
ROSTemplateFormatVersion: '2015-09-01'
Resources:
CustomResource:
Type: ALIYUN::ROS::CustomResource
Properties:
ServiceToken:
Ref: ServiceToken
Parameters:
Ref: Parameters
Timeout:
Ref: Timeout
Parameters:
ServiceToken:
Type: String
Description: 'The service token that was given to the template developer by the
service provider to access the service.Allowed values:- Function Compute: acs:fc:<region_id>:<account_id>:services/<service_name>/functions/<function_name>-
MNS Queue: acs:mns:<region_id>:<account_id>:queues/<queue_name>- MNS Topic:
acs:mns:<region_id>:<account_id>:topics/<topic_name>- HTTP&HTTPS: web[options]:<url> Two
options are supported: - sync: sync HTTP&HTTPS request. - idempotent: indicates
that the Create request is idempotent. Update and Delete requests should be
always idempotent.Examples: - acs:fc:cn-hangzhou:123456789:services/test-service/functions/test-function -
acs:mns:cn-hangzhou:123456789:queues/test-queue - acs:mns:cn-hangzhou:123456789:topics/test-topic -
web:https://abc.com - web[sync]:http://abc.com - web[sync,idempotent]:https://abc.com'
MaxLength: 512
Parameters:
Type: Json
Description: Parameters to be passed to service provider.
Timeout:
Default: 60
Type: Number
Description: Timeout seconds before service provider responses.It takes effects
only if the type of ServiceToken is Function Compute, MNS Queue, MNS Topic or
async HTTP&HTTPS request.Timeout seconds are always 10 for sync HTTP&HTTPS request.
MaxValue: 43200
MinValue: 1
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在供应商定义的属性中进行检索。