Updates a stack.

The values in the Parameters section are related to the UsePreviousParameters value in the request. If you do not specify the parameters that are defined in the template as the parameters in the Parameters section, take note of the following items:

  • The UsePreviousParameters value is false: If a parameter in the template has a default value, the default value is used. If the parameter in the template does not have a default value, you must set a value for the parameter in the Parameters section.
  • The UsePreviousParameters value is true: If you set a parameter in the template to a specific value when you create a stack, the value is used. If you do not set a parameter in the template to a specific value, but the parameter has a default value in the template, the default value is used.

In this example, the template content of a stack whose ID is 4a6c9851-3b0f-4f5f-b4ca-a14bf691∗∗∗∗ in the China (Beijing) region is updated to {"ROSTemplateFormatVersion": "2015-09-01"}.

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 UpdateStack

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

StackId String Yes 4a6c9851-3b0f-4f5f-b4ca-a14bf691∗∗∗∗

The ID of the stack.

ClientToken String No 123e4567-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 it 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.

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

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

If you want to update protected resources, specify a temporary overriding stack policy during the update. If you do not specify the policy, the existing policy that is associated with the stack is used.

This parameter only takes effect when the ChangeSetType parameter is set to UPDATE. You can specify only one of the following parameters:

  • StackPolicyBody
  • StackPolicyURL
  • StackPolicyDuringUpdateBody
  • StackPolicyDuringUpdateURL
TimeoutInMinutes Long No 10

The timeout period for the update operation on the stack.

  • Default value: 60.
  • Unit: minutes.
TemplateBody String No {"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 is longer than required, we recommend that you add parameters to the HTTP POST request body to prevent request failures caused by the excessively long URLs.

Note You must specify only one of the following parameters: TemplateBody, TemplateURL, and TemplateId.
StackPolicyURL String No oss://ros-stack-policy/demo

The URL of the file that contains the stack policy. The URL must point to a policy that is located on an HTTP or HTTPS web server or in an Alibaba Cloud Object Storage Service (OSS) bucket. Examples: oss://ros/stack-policy/demo and oss://ros/stack-policy/demo?RegionId=cn-hangzhou.The file can be up to 16,384 bytes in length. If you do not specify RegionId in the URL, the region ID of the stack is used.

Note You can specify only one of the following parameters: StackPolicyBody and StackPolicyURL.

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

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

The URL of the file that contains the temporary overriding stack policy. The URL must point to a policy that is located on an HTTP or HTTPS web server or in an Alibaba Cloud OSS bucket. Examples: oss://ros/stack-policy/demo and oss://ros/stack-policy/demo?RegionId=cn-hangzhou.The file can be up to 16,384 bytes in length.

Note If you do not specify RegionId in the URL, the region ID of the stack is used.

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

If you want to update protected resources, specify a temporary overriding stack policy during the update. If you do not specify a stack policy, the existing policy that is associated with the stack is used. This parameter only takes effect when the ChangeSetType parameter is set to UPDATE. You can specify only one of the following parameters:

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

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

Note You can specify only one of the following parameters: StackPolicyBody and StackPolicyURL.
UsePreviousParameters Boolean No true

Specifies whether to use the values that you set last time as the values of the parameters not specified in this request.

Valid values:

  • true: uses the values that you set last time as the values of the parameters not specified in this request.
  • false: does not use the values that you set last time as the values of the parameters not specified in this request.
RegionId String Yes cn-beijing

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

DisableRollback Boolean No false

Specifies whether to roll back the update operation on the stack when the stack fails to be updated.

Valid values:

  • true: rolls back the update operation.
  • false: does not roll back the update operation.
TemplateURL String No oss://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 Alibaba Cloud OSS bucket. Examples: oss://ros/template/demo and oss://ros/template/demo?RegionId=cn-hangzhou. The template body must be 1 to 524,288 bytes in length. Examples: oss://ros/template/demo or oss://ros/template/demo?RegionId=cn-hangzhou. If you do not specify RegionId in the URL, the region ID of the stack is used.

Note You must specify only one of the following parameters: TemplateBody, TemplateURL, and TemplateId.
RamRoleName String No test-role

The name of the RAM role. Resource Orchestration Service (ROS) assumes the RAM role to create the stack and uses the credential of the role to call the APIs of Alibaba Cloud services.

ROS assumes the role to perform operations on the stack. If you are authorized to perform operations on the stack but do not have permissions to use the role, ROS uses the role and you must make sure that least privileges are granted to this role.

If you do not specify this parameter, ROS uses the existing role that is associated with the stack. If no roles are available for ROS to assume, ROS uses the temporary credential that is generated from the credentials of your account.

The name can be up to 64 bytes in length.

ReplacementOption String No Disabled

Specifies whether to enable the replacement update feature. If resource properties cannot be modified for an update, you can enable the replacement update feature to replace the resource properties. After the replacement update feature is enabled, the existing resource is deleted and a new resource is created. The physical ID of the new resource is different from that of the existing resource.

Default value: Disabled. Valid values:

  • Enabled: enables the replacement update feature.
  • Disabled: disables the replacement update feature.
Note Operations that you perform to modify the resource properties for an update take precedence over operations you perform to replace the resource properties for an update.
TemplateId String No 5ecd1e10-b0e9-4389-a565-e4c15efc∗∗∗∗

The ID of the template. This parameter applies to shared and private templates.

Note You must specify only one of the following parameters: TemplateBody, TemplateURL, and TemplateId.
TemplateVersion String No v1

The version of the template. This parameter only takes effect when the TemplateId parameter is specified.

Parallelism Long No 1

The maximum number of operations that are concurrently performed on a resource. This parameter only takes effect for Terraform stacks.

This parameter is empty by default. You can set this parameter to an integer greater than or equal to 0.

Note
  • If you set this parameter to an integer greater than 0, the integer is used as the maximum number of operations.
  • If you set this parameter to 0, the default value of Terraform is used as the maximum number of resources. In most cases, the default value of Terraform is 10.
  • If you do not set this parameter, the value that you set for this parameter in the last operation is used. If you did not set this parameter in the last operation, the default value of Terraform is used. In most cases, the default value of Terraform is 10.
  • If you set this parameter, ROS associates the value with the stack and the value can affect subsequent operations on the stack.
Parameters.N.ParameterKey String Yes Amount

The key of parameter N. If you do not specify the key and value of the parameter, the key and value in the template are used.

Maximum value of N: 200.

Note Parameters in Parameters.N.ParameterKey is optional. If you need to specify Parameters, you must specify the Parameters.N.ParameterKey and Parameters.N.ParameterValue parameters.
Parameters.N.ParameterValue String Yes 12

The value of parameter N. Maximum value of N: 200.

Note Parameters in Parameters.N.ParameterValue is optional. If you need to specify Parameters, you must specify the Parameters.N.ParameterKey and Parameters.N.ParameterValue parameters.
Tags.N.Key String Yes usage

The key of tag N of the stack.

Valid values of N: 1 to 20.

Note Tags in Tags.N.Key is optional. If you need to specify Tags, you must specify the Tags.N.Key parameter.
Tags.N.Value String No test

The value of tag N of the stack.

Valid values of N: 1 to 20.

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

Response parameters

Parameter Type Example Description
RequestId String B288A0BE-D927-4888-B0F7-B35EF84B6E6F

The ID of the request.

StackId String 4a6c9851-3b0f-4f5f-b4ca-a14bf691∗∗∗∗

The ID of the stack.

Examples

Sample requests

https://ros.aliyuncs.com/?Action=UpdateStack
&RegionId=cn-beijing
&StackId=4a6c9851-3b0f-4f5f-b4ca-a14bf691****
&TemplateBody={"ROSTemplateFormatVersion": "2015-09-01"}
&<Common request parameters>

Sample success responses

XML format

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

<UpdateStackResponse>
    <StackId>4a6c9851-3b0f-4f5f-b4ca-a14bf691****</StackId>
    <RequestId>B288A0BE-D927-4888-B0F7-B35EF84B6E6F</RequestId>
</UpdateStackResponse>

JSON format

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

{
  "StackId" : "4a6c9851-3b0f-4f5f-b4ca-a14bf691****",
  "RequestId" : "B288A0BE-D927-4888-B0F7-B35EF84B6E6F"
}

Error codes

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

HttpCode

Error code

Error message

Description

400

CircularDependency

Circular Dependency Found: {reason}.

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

400

InvalidSchema

{reason}.

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

400

InvalidTemplateAttribute

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

The error message returned because the resource property that is referenced in the Outputs section of the template is invalid. resource indicates the resource name. name indicates the property name.

400

InvalidTemplatePropertyType

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

The error message returned because the type of the specified resource property that is defined in the template is invalid. resource indicates the resource name. section indicates the section name.

400

InvalidTemplateReference

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

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

400

InvalidTemplateSection

The template section is invalid: {section}.

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

400

InvalidTemplateVersion

The template version is invalid: {reason}.

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

400

StackPolicyValidationFailed

Action denied by stack policy: {reason}.

The error message returned because the stack policy fails to be validated. reason indicates the specific reason.

400

StackValidationFailed

{reason}.

The error message returned because the stack fails to be validated. reason indicates the specific reason.

400

UnknownUserParameter

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

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

400

UserParameterMissing

The Parameter {name} was not provided.

The error message returned because no value is set for the parameter specified in the template. name indicates the parameter name.

404

StackNotFound

The Stack ({name}) could not be found.

The error message returned because the specified stack does not exist. name indicates the stack name or ID.

409

ActionInProgress

Stack {name} already has an action ({action}) in progress.

The error message returned because the specified stack is being changed. name indicates the stack name or ID. action indicates the change operation.

404

TemplateNotFound

The Tempalte ({ ID }) could not be found.

The error message returned because the specified template does not exist. ID indicates the template ID.

404

TemplateNotFound

The Template { ID } with version { version } could not be found.

The error message returned because the specified template or template version does not exist. ID indicates the template ID. version indicates the template version.