You can call this operation to preview the stack to be created using a specified template.

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

Parameter Type Required Example Description
Action String Yes PreviewStack

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

RegionId String Yes cn-beijing

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

StackName String Yes MyStack

The name of the stack. The name can be up to 255 characters in length and can contain digits, letters, hyphens (-), and underscores (_). It must start with a digit or letter.

TimeoutInMinutes Long Yes 10

The timeout period that is specified for the stack preview request. Unit: minutes.

Default value: 10.

Parameters.N.ParameterValue String No ecs.cm4.6xlarge

The value of parameter N.

Maximum value of N: 200.

Parameters.N.ParameterKey String No InstanceType

The name of parameter N. If the name and value of the parameter are not specified, the name and value specified in the template are used.

Maximum value of N: 200.

DisableRollback Boolean No false

Specifies whether to disable rollback on stack creation failure. Default value: false. Valid values:

  • true: disables rollback on stack creation failure.
  • false: enables rollback on stack creation failure.
TemplateBody String No { "ROSTemplateFormatVersion": "2015-09-01" }

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

You must specify either the TemplateBody parameter or the TemplateURL parameter. But you cannot specify both of them.

StackPolicyURL String No oss://ros-stack-policy/demo

The URL for the file that contains the stack policy. The URL must point to a policy located in an HTTP or HTTPS web server or an Alibaba Cloud OSS bucket. Examples: oss://ros/stack-policy/demo and oss://ros/stack-policy/demo?RegionId=cn-hangzhou. If the region of the OSS bucket is not specified, the RegionId parameter value is used by default. The policy can be up to 16,384 bytes in length and the URL can be up to 1,350 bytes in length.

You can specify either the StackPolicyBody parameter or the StackPolicyURL parameter. But you cannot specify both of them.

StackPolicyBody String No {"Statement": [{"Action": "Update:*", "Resource": "*", "Effect": "Allow", "Principal": "*"}]}

The structure that contains the stack policy body. The policy body must be 1 to 16,384 bytes in length.

You can specify either the StackPolicyBody parameter or the StackPolicyURL parameter. But you cannot specify both of them.

TemplateURL String No oss://ros-template/demo

The URL for the file that contains the template body. The URL must point to a template located in an HTTP or HTTPS web server or an Alibaba Cloud OSS bucket. Examples: oss://ros/template/demo and oss://ros/template/demo?RegionId=cn-hangzhou. If the region of the OSS bucket is not specified, the RegionId parameter value is used by default. The template can be up to 524,288 bytes in length.

You must specify either the TemplateBody parameter or the TemplateURL parameter. But you cannot specify both of them.

ClientToken String No 123e4567-e89b-12d3-a456-426655440000

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 ensure that it is unique among different requests. It can only contain letters, digits, hyphens (-), and underscores (_) and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

Response parameters

Parameter Type Example Description
Stack Map The Stack field in sample success responses

The stack information.

RequestId String B288A0BE-D927-4888-B0F7-B35EF84B6E6F

The ID of the request.

Examples

Sample requests


http(s)://ros.aliyuncs.com/? Action=PreviewStack
&RegionId=cn-beijing
&Parameters.1.ParameterValue=ecs.cm4.6xlarge
&Parameters.1.ParameterKey=InstanceType
&StackName=MyStack
&TimeoutInMinutes=10
&<Common request parameters>

Sample success responses

XML format

<PreviewStackResponse>
      <Stacks>
            <Description>No description</Description>
            <DisableRollback>true</DisableRollback>
            <Parameters>
                  <Parameter>
                        <ParameterKey>UpdateVersion</ParameterKey>
                        <ParameterValue>1</ParameterValue>
                  </Parameter>
            </Parameters>
            <RegionId>cn-beijing</RegionId>
            <Resources>
                  <Resource>
                        <Description></Description>
                        <LogicalResourceId>WaitConditionHandle</LogicalResourceId>
                        <Properties>
                              <Count>-1</Count>
                              <Mode>Full</Mode>
                              <UpdateVersion>1</UpdateVersion>
                        </Properties>
                        <RequiredBy></RequiredBy>
                        <ResourceType>ALIYUN::ROS::WaitConditionHandle</ResourceType>
                  </Resource>
                  <Resource>
                        <Description></Description>
                        <LogicalResourceId>nested</LogicalResourceId>
                        <Properties>
                              <Parameters></Parameters>
                              <TemplateURL>oss://nested-stack/simple/nested_demo</TemplateURL>
                              <TimeoutMins>16</TimeoutMins>
                        </Properties>
                        <RequiredBy></RequiredBy>
                        <ResourceType>ALIYUN::ROS::Stack</ResourceType>
                        <Stack>
                              <Description>No description</Description>
                              <DisableRollback>true</DisableRollback>
                              <Parameters>
                                    <Parameter>
                                          <ParameterKey>ALIYUN::AccountId</ParameterKey>
                                          <ParameterValue>16xxxxxxxx1</ParameterValue>
                                          <ParameterKey>ALIYUN::NoValue</ParameterKey>
                                          <ParameterValue>None</ParameterValue>
                                          <ParameterKey>ALIYUN::Region</ParameterKey>
                                          <ParameterValue>cn-beijing</ParameterValue>
                                          <ParameterKey>ALIYUN::StackId</ParameterKey>
                                          <ParameterValue>None</ParameterValue>
                                          <ParameterKey>ALIYUN::StackName</ParameterKey>
                                          <ParameterValue>test-preview-stack-complex-nested</ParameterValue>
                                    </Parameter>
                              </Parameters>
                              <RegionId>cn-beijing</RegionId>
                              <Resources>
                                    <Resource>
                                          <Description></Description>
                                          <LogicalResourceId>WaitConditionHandle</LogicalResourceId>
                                          <Properties>
                                                <Count>-1</Count>
                                                <Mode>Full</Mode>
                                                <UpdateVersion>1</UpdateVersion>
                                          </Properties>
                                          <RequiredBy></RequiredBy>
                                          <ResourceType>ALIYUN::ROS::WaitConditionHandle</ResourceType>
                                    </Resource>
                              </Resources>
                              <StackName>test-preview-stack-complex-nested</StackName>
                              <StackPolicyBody>
                                    <Statement>
                                          <Statement>
                                                <Action>Update:*</Action>
                                                <Effect>Allow</Effect>
                                                <Principal>*</Principal>
                                                <Resource>*</Resource>
                                          </Statement>
                                    </Statement>
                              </StackPolicyBody>
                              <TemplateDescription>No description</TemplateDescription>
                              <TimeoutInMinutes>12</TimeoutInMinutes>
                        </Stack>
                  </Resource>
            </Resources>
            <StackName>test-preview-stack-complex</StackName>
            <StackPolicyBody>
                  <Statement>
                        <Statement>
                              <Action>Update:*</Action>
                              <Effect>Allow</Effect>
                              <Principal>*</Principal>
                              <Resource>*</Resource>
                        </Statement>
                  </Statement>
            </StackPolicyBody>
            <TemplateDescription>No description</TemplateDescription>
            <TimeoutInMinutes>10</TimeoutInMinutes>
      </Stacks>
      <RequestId>B288A0BE-D927-4888-B0F7-B35EF84B6E6F</RequestId>    
</PreviewStackResponse>

JSON format

{
	"Stack":{
		"Parameters":[
			{
				"ParameterValue":"1",
				"ParameterKey":"UpdateVersion"
			}
		],
		"TimeoutInMinutes":10,
		"TemplateDescription":"No description",
		"Description":"No description",
		"StackPolicyBody":{
			"Statement":[
				{
					"Resource":"*",
					"Principal":"*",
					"Action":"Update:*",
					"Effect":"Allow"
				},
				{
					"Resource":"LogicalResourceId/apple1",
					"Principal":"*",
					"Action":"Update:*",
					"Effect":"Deny"
				}
			]
		},
		"RegionId":"cn-beijing",
		"DisableRollback":true,
		"StackName":"test-preview-stack-complex",
		"Resources":[
			{
				"RequiredBy":[],
				"LogicalResourceId":"WaitConditionHandle",
				"Description":"",
				"ResourceType":"ALIYUN::ROS::WaitConditionHandle",
				"Properties":{
					"UpdateVersion":1,
					"Count":-1,
					"Mode":"Full"
				}
			},
			{
				"Stack":{
					"Parameters":[
						{
							"ParameterValue":"16xxxxxxxx1",
							"ParameterKey":"ALIYUN::AccountId"
						},
						{
							"ParameterValue":"None",
							"ParameterKey":"ALIYUN::NoValue"
						},
						{
							"ParameterValue":"cn-beijing",
							"ParameterKey":"ALIYUN::Region"
						},
						{
							"ParameterValue":"None",
							"ParameterKey":"ALIYUN::StackId"
						},
						{
							"ParameterValue":"test-preview-stack-complex-nested",
							"ParameterKey":"ALIYUN::StackName"
						}
					],
					"TimeoutInMinutes":12,
					"TemplateDescription":"No description",
					"Description":"No description",
					"StackPolicyBody":{
						"Statement":[
							{
								"Resource":"*",
								"Principal":"*",
								"Action":"Update:*",
								"Effect":"Allow"
							},
							{
								"Resource":"LogicalResourceId/apple1",
								"Principal":"*",
								"Action":"Update:*",
								"Effect":"Deny"
							}
						]
					},
					"RegionId":"cn-beijing",
					"DisableRollback":true,
					"StackName":"test-preview-stack-complex-nested",
					"Resources":[
						{
							"RequiredBy":[],
							"LogicalResourceId":"WaitConditionHandle",
							"Description":"",
							"ResourceType":"ALIYUN::ROS::WaitConditionHandle",
							"Properties":{
								"UpdateVersion":1,
								"Count":-1,
								"Mode":"Full"
							}
						}
					]
				},
				"RequiredBy":[],
				"LogicalResourceId":"nested",
				"Description":"",
				"ResourceType":"ALIYUN::ROS::Stack",
				"Properties":{
					"TemplateURL":"oss://nested-stack/simple/nested_demo",
					"TimeoutMins":16
				}
			}
		]
	},
	"RequestId":"B288A0BE-D927-4888-B0F7-B35EF84B6E6F"
}

Error codes

For a list of error codes, visit the API Error Center.

For more information about errors common to all operations, see Common errors.

Error code

Error message

HTTP status code

Description

CircularDependency

Circular Dependency Found: {reason}.

400

The error message returned because the template contains a circular dependency. reason indicates the specific reason.

InvalidSchema

{reason}.

400

The error message returned because the template format is incorrect. reason indicates the specific reason.

InvalidTemplateAttribute

The Referenced Attribute ({resource} {name}) is incorrect.

400

The error message returned because the resource attribute referenced in the template is incorrect. resource indicates the resource name, and name indicates the attribute name.

InvalidTemplatePropertyType

The specified value type of ({resource} {section}) is incorrect.

400

The error message returned because the type of the resource property defined in the template is incorrect. resource indicates the resource name, and section indicates the property name.

InvalidTemplateReference

The specified reference "{name}" (in {referencer}) is incorrect.

400

The error message returned because the template contains an invalid reference. name indicates the reference name, and referencer indicates the referencer name.

InvalidTemplateSection

The template section is invalid: {section}.

400

The error message returned because the template contains an invalid property. section indicates the property name.

InvalidTemplateVersion

The template version is invalid: {reason}.

400

The error message returned because the template version is incorrect. reason indicates the specific reason.

StackValidationFailed

{reason}.

400

The error message returned because the stack validation failed. reason indicates the specific reason.

UnknownUserParameter

The Parameter ({name}) was not defined in template.

400

The error message returned because the specified parameter is not defined in the template. name indicates the parameter name.

UserParameterMissing

The Parameter {name} was not provided.

400

The error message returned because no value is passed into the specified parameter defined in the template. name indicates the parameter name.

StackExists

The Stack ({name}) already exists.

409

The error message returned because a stack with the same name already exists. name indicates the stack name.