Validates a template that you want to use to create a stack.

This topic provides an example on how to validate a template that you want to use to create a stack. In this example, the TemplateURL parameter is set to oss://ros/template/demo.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesValidateTemplate

The operation that you want to perform. Set the value to ValidateTemplate.

TemplateURLStringNooss://ros/template/demo

The URL of the file that contains the template body. The URL must point to a template that is located on an HTTP or HTTPS web server or in an Object Storage Service (OSS) bucket, such as oss://ros/template/demo or oss://ros/template/demo?RegionId=cn-hangzhou. The template body can be up to 524,288 bytes in length.

Note If you do not specify the region ID of the OSS bucket, the value of the RegionId parameter is used.

You can specify only one of the TemplateBody and TemplateURL parameters.

The URL can be up to 1,024 bytes in length.

RegionIdStringNocn-hangzhou

The ID of the region where the template resides. You can call the DescribeRegions operation to query the most recent region list.

TemplateBodyStringNo{"ROSTemplateFormatVersion":"2015-09-01"}

The structure that contains the template body. The template body must be 1 to 524,288 bytes in length.

If the length of the template body exceeds the upper limit, we recommend that you add parameters to the HTTP POST request body to prevent request failures caused by excessively long URLs.

You can specify only one of the TemplateBody and TemplateURL parameters.

ClientTokenStringNo123e4567-e89b-12d3-a456-42665544****

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that the value is unique among different requests.

The token can be up to 64 characters in length, and can contain letters, digits, hyphens (-), and underscores (_).

For more information, see Ensure idempotence.

ValidationOptionStringNoNone

Specifies whether to enable additional validation for the template. Default value: None. Valid values:

  • None: does not enable additional validation.
  • EnableTerraformValidation: runs the terraform validate command in the Terraform CLI to enable additional validation for a Terraform template.
  • EnableFastTerraformValidation: runs a command that is similar to the terraform validate command in the Terraform CLI to enable additional validation for a Terraform template.
    Note Compared with the EnableTerraformValidation method, the EnableFastTerraformValidation method validates a template at a faster speed, but lower integrity level.

For more information about common request parameters, see Common parameters.

Response parameters

ParameterTypeExampleDescription
DescriptionStringNo description

The description of the template.

ParametersArray of Object[{"Description": "", "Label": "param_integer", "NoEcho": "false", "ParameterKey": "param_integer", "Type": "Number"},{ "Description": "", "Label": "param_float", "NoEcho": "false", "ParameterKey": "param_float", "Type": "Number"}]

The parameters in the Parameters section of the template.

The Parameters section contains the parameters that you must specify when you use the template to create a stack. You can use the parameters to specify the stack details, such as the username, the password, and the Elastic Compute Service (ECS) instance type in the specified region.

RequestIdStringB288A0BE-D927-4888-B0F7-B35EF84B6E6F

The ID of the request.

OutputsArray of Output

The output items of the template.

OutputKeyStringinstance_id

The name of the output item.

DescriptionStringThe instance ID of my ECS.

The description of the output item.

LabelStringInstance ID

The alias of the output item.

ResourceTypesObject

The resource types that are used in the template.

ResourcesArray of StringALIYUN::ECS::InstanceGroup

The regular resource types.

DataSourcesArray of StringDATASOURCE::VPC::Vpcs

The DataSource resource types.

ResourcesArray of Resource

The regular resources that are defined in the template.

Note
  • For a Resource Orchestration Service (ROS) template, the resource whose definition contains the Count parameter is not displayed as a list.
  • For a Terraform template, the resource whose definition contains the count or for_each parameter is not displayed as a list.
ResourceTypeStringALIYUN::ECS::InstanceGroup

The regular resource type.

ResourcePathStringserver

The path of the regular resource. In most cases, the path of a regular resource is the same as the resource name.

LogicalResourceIdPatternStringserver

The pattern in which the logical IDs of regular resources are formed.

If resources are defined in an ROS template, the following rules apply:

  • Resource whose definition does not contain the Count parameter: If the resource name defined in the template is server, the value of the LogicalResourceIdPattern and ResourcePath parameters is server.
  • Resource whose definition contains the Count parameter: If the resource name defined in the template is server, the value of the LogicalResourceIdPattern parameter is server[*], and the value of the ResourcePath parameter is server.

If resources and modules are defined in a Terraform template, the following rules apply:

  • Resource and module whose definitions do not contain the count or for_each parameter: If the resource name defined in the template is server, the value of the LogicalResourceIdPattern and ResourcePath parameters is server.
  • Resource and module whose definitions contain the count or for_each parameter: If the resource name defined in the template is server, the value of the LogicalResourceIdPattern parameter is server[*], and the value of the ResourcePath parameter is server.

Examples of the LogicalResourceIdPattern parameter for resources in a Terraform template:

  • Valid values of the LogicalResourceIdPattern parameter if a resource belongs to the root module:
    • server: In this case, the count or for_each parameter is not contained in the resource. The value of the ResourcePath parameter is server.
    • server[*]: In this case, the count or for_each parameter is contained in the resource. The value of the ResourcePath parameter is server.
  • Valid values of the LogicalResourceIdPattern parameter if a resource belongs to a child module:
    • app.server: In this case, the count or for_each parameter is not contained in the app module and the server resource. The value of the ResourcePath parameter is app.server.
    • app.server[*]: In this case, the count or for_each parameter is contained in the server resource, but not in the app module. The value of the ResourcePath parameter is app.server.
    • app[*].server: In this case, the count or for_each parameter is contained in the app module, but not in the server resource. The value of the ResourcePath parameter is app.server.
    • app[*].server[*]: In this case, the count or for_each parameter is contained in the app module and the server resource. The value of the ResourcePath parameter is app.server.
    • app.app_group[*].server: In this case, the count or for_each parameter is contained in the app_group module, but not in the app module and the server resource. The value of the ResourcePath parameter is app.app_group.server. The app_group module is a child module of the app module.
UpdateInfoObject

The update information about the stack.

ParametersAllowedToBeModifiedArray of Stringparam1

The parameters that can be modified. If you change only values of the parameters in a stack template and use the template to update the stack, no validation errors are caused.

ParametersCauseInterruptionIfModifiedArray of Stringparam1

The parameters whose changes cause service interruptions. If you change only values of the parameters in a stack template and use the template to update the stack, service interruptions are caused.

Note
  • This parameter is supported only for a small number of resource types.
  • This parameter is valid only for changes that are made on ROS stacks.
ParametersConditionallyAllowedToBeModifiedArray of Stringparam2

The parameters that can be modified under specific conditions. If you change only values of the parameters in a stack template and use the template to update the stack, the new values of the parameters determine whether validation errors are caused.

ParametersConditionallyCauseInterruptionIfModifiedArray of Stringparam2

The parameters whose changes cause service interruptions under specific conditions. If you change only values of the parameters in a stack template and use the template to update the stack, the new values and the update type determine whether service interruptions are caused.

Note
  • This parameter is supported only for a small number of resource types.
  • This parameter is valid only for changes that are made on ROS stacks.
ParametersNotAllowedToBeModifiedArray of Stringparam3

The parameters that cannot be modified. If you change only values of the parameters in a stack template and use the template to update the stack, validation errors are caused.

ParametersUncertainlyAllowedToBeModifiedArray of Stringparam4

The parameters that can be modified under uncertain conditions. If you change only values of the parameters in a stack template and use the template to update the stack, the actual running environment determines whether validation errors are caused.

ParametersUncertainlyCauseInterruptionIfModifiedArray of Stringparam4

The parameters whose changes cause service interruptions under uncertain conditions. If you change only values of the parameters in a stack template and use the template to update the stack, the actual running environment determines whether service interruptions are caused.

Note
  • This parameter is supported only for a small number of resource types.
  • This parameter is valid only for changes that are made on ROS stacks.

Examples

Sample requests

http(s)://ros.aliyuncs.com/?Action=ValidateTemplate
&TemplateURL=oss://ros/template/demo
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ValidateTemplateResponse>
    <Description>No description</Description>
    <Parameters>
        <Description/>
        <Label>param_integer</Label>
        <NoEcho>false</NoEcho>
        <ParameterKey>param_integer</ParameterKey>
        <Type>Number</Type>
    </Parameters>
    <Parameters>
        <Description/>
        <Label>param_float</Label>
        <NoEcho>false</NoEcho>
        <ParameterKey>param_float</ParameterKey>
        <Type>Number</Type>
    </Parameters>
    <RequestId>B288A0BE-D927-4888-B0F7-B35EF84B6E6F</RequestId>
    <Outputs>
        <OutputKey>instance_id</OutputKey>
        <Description>The instance ID of my ECS.</Description>
    </Outputs>
    <ResourceTypes>
        <Resources>ALIYUN::ECS::InstanceGroup</Resources>
        <DataSources>DATASOURCE::VPC::Vpcs</DataSources>
    </ResourceTypes>
</ValidateTemplateResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Description" : "No description",
  "Parameters" : [ {
    "Description" : "",
    "Label" : "param_integer",
    "NoEcho" : "false",
    "ParameterKey" : "param_integer",
    "Type" : "Number"
  }, {
    "Description" : "",
    "Label" : "param_float",
    "NoEcho" : "false",
    "ParameterKey" : "param_float",
    "Type" : "Number"
  } ],
  "RequestId" : "B288A0BE-D927-4888-B0F7-B35EF84B6E6F",
  "Outputs" : {
    "OutputKey" : "instance_id",
    "Description" : "The instance ID of my ECS."
  },
  "ResourceTypes" : {
    "Resources" : "ALIYUN::ECS::InstanceGroup",
    "DataSources" : "DATASOURCE::VPC::Vpcs"
  }
}

Error codes

For a list of error codes, see Service error codes.

Error code

Error message

HTTP status code

Description

InvalidTemplate

{reason}.

400

The error message returned because the specified template is invalid. reason indicates the cause of the error.

IInvalidParameter

{reason}.

400

The error message returned because the specified parameter in the template is invalid. reason indicates the cause of the error.