ALIYUN::ROS::CustomResource

更新时间:
复制 MD 格式

ALIYUN::ROS::CustomResource creates a custom resource that runs your own configuration logic during stack operations.

In ROS templates, use ALIYUN::ROS::CustomResource or Custom::String to define a custom resource.

Custom resources let you embed configuration logic in templates that ROS runs during stack create, update, or delete operations. Overview of custom resources.

A custom resource must send a response to a presigned URL, or the stack operation fails. ResponseURL supports the public network; InnerResponseURL supports 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 provided by the service provider for accessing the service.

Currently, support is provided for Function Compute function, SMQ (

Simple Message Queue (formerly MNS)

) Topic, SMQ Queue, HTTP&HTTPS.

Maximum length: 512 characters.

Valid values:

  • FC 2.0: acs:fc:<region_id>:<account_id>:services/<service_name>/functions/<function_name>

  • FC 3.0: acs:fc:<region_id>:<account_id>:functions/<function_name>

  • SMQ queue: acs:mns:<region_id>:<account_id>:queues/<queue_name>

  • SMQ topic: acs:mns:<region_id>:<account_id>:topics/<topic_name>

  • HTTP & HTTPS: web[options]:<url>

    options is optional. Valid values: sync and idempotent. Separate multiple values with a comma (,).

    sync: Synchronous mode. ROS uses the direct response instead of waiting for a presigned URL callback. Default behavior is asynchronous.

    idempotent: Makes create requests idempotent. ROS retries on network errors or 500 responses. Create requests are not idempotent by default. Update and delete requests are 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://example.com

  • web[sync]:http://example.com

  • web[sync,idempotent]:https://example.com

Timeout

Number

Yes

Yes

Timeout for the custom service provider to respond, in seconds.

  • If ServiceToken specifies an FC function, an SMQ topic, an SMQ queue, or an asynchronous HTTP or HTTPS request, the default value of Timeout is 60. The value must be between 1 and 43200.

  • If ServiceToken specifies a synchronous HTTP or HTTPS request, Timeout is ignored. The timeout period is always 10 seconds.

Parameters

Map

No

Yes

Parameters to pass to the custom service provider. Define according to the provider's specifications.

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

    You can use ALIYUN::ROS::CustomResource as the resource type or define your own name. For example, 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.

    Custom type names help distinguish resources in your stack. For example, name two ping-testing resources Custom::PingTester to identify them at a glance.

  • Replacing custom resources during updates

    The PhysicalResourceId of a resource cannot be replaced during an update in ROS.

  • Retrieve return values

    Return values are defined by the custom service provider. Retrieve them from the provider-defined properties by calling Fn::GetAtt.