ALIYUN::ROS::CustomResource lets you create a custom resource.
In an ROS template, you can use the ALIYUN::ROS::CustomResource or Custom::String resource type to define a custom resource.
Custom resources allow you to write custom configuration logic in an ROS template. ROS runs this logic during stack operations, such as when you create, update, or delete a stack. For more information, see Overview of custom resources.
A custom resource must send a response to a presigned response URL. If ROS does not receive a response, the stack operation fails. ResponseURL enables responses over the public network, and InnerResponseURL enables responses over the Alibaba Cloud private network.
Syntax
{
"Type": "ALIYUN::ROS::CustomResource",
"Properties": {
"ServiceToken": String,
"Timeout": Number,
"Parameters": Map
}
}Properties
Property | Type | Required | Enable updates | Description | Constraints |
ServiceToken | String | Yes | No | The service token that the service provider gives to the template developer to access the service. Currently, support is provided for Function Compute function, SMQ ( Simple Message Queue (formerly MNS) ) Topic, SMQ Queue, HTTP&HTTPS. It can be up to 512 characters in length. | Valid values:
Examples:
|
Timeout | Number | Yes | Yes | The timeout period for the custom service provider to respond. Unit: seconds. |
|
Parameters | Map | No | Yes | The parameters to pass to the custom service provider. Specify this property according to the specifications from the custom service provider. | None. |
Return values
Fn::GetAtt
Outputs: The data returned by the custom service provider, which is a map object.
*: A key in the Outputs map.
Examples
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"
]
}
}
}
}Remarks
Specify a name for a custom resource type
For a custom resource, you can use ALIYUN::ROS::CustomResource as the resource type or specify your own resource type name. For example, you can use Custom::MyCustomResourceTypeName instead of ALIYUN::ROS::CustomResource.
The name of a custom resource type can contain letters, numbers, and the following special characters:
_@-. The name can be up to 68 characters in length. You cannot change the type during an update.Using your own resource type names helps you quickly distinguish the types of custom resources in your stack. For example, if you have two custom resources that perform two different ping tests, you can specify the resource type as Custom::PingTester instead of ALIYUN::ROS::CustomResource to easily identify them as ping testers.
Replacing custom resources during updates
The PhysicalResourceId of a resource cannot be replaced during an update in ROS.
Retrieve return values
For custom resources, the return values are defined by the custom service provider. You can retrieve these values from the provider-defined properties by calling Fn::GetAtt.