Updates a stack.

The values of Parameters and UsePreviousParameters in the request are related. If parameters defined in the template are not specified in the Parameters section, take note of the following items:

  • When UsePreviousParameters is set to false, if a parameter in the template has a default value, the default value is preferred. If the parameter in the template does not have a default value, you must specify a value for the parameter in the Parameters section.
  • When UsePreviousParameters is set to true, if a parameter is specified when the stack is created, the specified value is preferred. If the parameter is not specified, but it has a default value in the template, the default value is preferred.

This topic provides an example on how to update the template content of the stack whose ID is 4a6c9851-3b0f-4f5f-b4ca-a14bf691**** in the China (Beijing) region 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 How to 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 stack policy body must be 1 to 16,384 bytes in length.

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

This parameter takes effect only 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 that is specified for the stack update request.

  • 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 due to excessive length of URLs.

Note You must specify one of the TemplateBody, TemplateURL, and TemplateId parameters.
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 located in an HTTP or HTTPS web server or an Alibaba Cloud Object Storage Service (OSS) bucket. Examples: oss://ros/stack-policy/demo and oss://ros/stack-policy/demo?RegionId=cn-hangzhou. The policy file can be up to 16,384 bytes in length. If the region of the OSS bucket is not specified, the RegionId value is used.

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

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 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. The policy file can be up to 16,384 bytes in length.

Note If the region of the OSS bucket is not specified, the RegionId value is used.

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

To update protected resources, specify a temporary overriding stack policy during the update. If you do not specify a stack policy, the current policy that is associated with the stack is used. This parameter takes effect only 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 stack policy body. The stack policy body must be 1 to 16,384 bytes in length.

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

Specifies whether to use the values that were passed last time for the parameters that you do not specify in the current request. Valid values:

  • true: uses the values that were passed last time for the parameters that you do not specify in the current request.
  • false: does not use the values that were passed last time for the parameters that you do not specify in the current 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 forcibly start a rollback task when the stack fails to be updated. Valid values:

  • true
  • false
TemplateURL String No oss://ros-template/demo

The URL of 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. The template body must be 1 to 524,288 bytes in length. If the region of the OSS bucket is not specified, the RegionId value is used.

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

The name of the Resource Access Management (RAM) role. ROS assumes the specified RAM role to create the stack and call API operations by using the credentials of the role.

All operations are performed under this role. If a RAM user is authorized to perform operations on the stack but does not have the permissions to use the role, ROS grants the minimum privileges required and continues to use the role.

If you do not specify this parameter, ROS uses the role previously associated with the stack. If no roles are available, ROS uses the temporary credentials generated from the credentials of your account.

The RAM role name can be up to 64 bytes in length.

ReplacementOption String No Disabled

Specifies whether to enable the replacement update feature. If a resource cannot be modified or updated, you can enable the replacement update feature for the resource. When 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 previous resource.

Valid values:

  • Enabled: enables replacement update.
  • Disabled: disables replacement update.
Note Modification update takes precedence over replacement 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 one of the TemplateBody, TemplateURL, and TemplateId parameters.
TemplateVersion String No v1

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

Parameters.N.ParameterKey String Yes Amount

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

Maximum value of N: 200.

Note
  • The Parameters parameter is optional.
  • If you need to specify Parameters, you must specify both Parameters.N.ParameterKey and Parameters.N.ParameterValue.
Parameters.N.ParameterValue String Yes 12

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

Note
  • The Parameters parameter is optional.
  • If you need to specify Parameters, you must specify both Parameters.N.ParameterKey and Parameters.N.ParameterValue.
Tags.N.Key String Yes usage

The key of tag N of the stack.

Valid values of N: 1 to 20.

Note
  • The Tags parameter is optional.
  • If you need to specify Tags, you must specify Tags.N.Key.
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. The reason parameter indicates the specific reason.

400

InvalidSchema

{reason}.

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

400

InvalidTemplateAttribute

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

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

400

InvalidTemplatePropertyType

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

The error message returned because the type of the specified resource section defined in the template is invalid. The resource parameter indicates the resource name, and the section parameter 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. The name parameter indicates the reference name, and the referencer parameter indicates the referencer name.

400

InvalidTemplateSection

The template section is invalid: {section}.

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

400

InvalidTemplateVersion

The template version is invalid: {reason}.

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

400

StackPolicyValidationFailed

Action denied by stack policy: {reason}.

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

400

StackValidationFailed

{reason}.

The error message returned because the stack validation failed. The reason parameter 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. The name parameter indicates the parameter key.

400

UserParameterMissing

The Parameter {name} was not provided.

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

404

StackNotFound

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

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

409

ActionInProgress

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

The error message returned because the specified stack has a change operation in progress. The name parameter indicates the name or ID of the stack, and the action parameter indicates the change operation.

404

TemplateNotFound

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

The error message returned because the specified template does not exist. The ID parameter 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. The ID parameter indicates the template ID, and the version parameter indicates the template version.