Creates a change set.

Description

You can create and execute change sets to update running stacks. For more information about change sets, see Overview.

Limits

  • A stack can contain up to 20 change sets.
  • Change sets reflect only changes on stacks. Change sets do not reflect whether stacks are updated.
  • You cannot use change sets to check the following items: whether the upper limit of your account is reached, whether resources that cannot be updated are updated, and whether your account has permissions to modify resources. These items may cause stack updates to fail. If stacks fail to be updated, Resource Orchestration Service (ROS) attempts to roll back your resources to the original status.

In this example, a change set named MyChangeSet is created in the China (Hangzhou) region. The change set is used to change the template of a stack to {"ROSTemplateFormatVersion":"2015-09-01"}. The ID of the stack is 4a6c9851-3b0f-4f5f-b4ca-a14bf691****.

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 CreateChangeSet

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

StackId String No 4a6c9851-3b0f-4f5f-b4ca-a14bf691****

The ID of the stack for which you want to create the change set. ROS compares the stack information with the information that you specify, such as a modified template or different values of input parameters, to generate the change set.

Note This parameter only takes effect when the ChangeSetType parameter is set to UPDATE or IMPORT.
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, for example, 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 you do not specify the region of the OSS bucket, the value of the RegionId parameter is used.

You can specify the StackPolicyBody or StackPolicyURL parameter.

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

If you set the ChangeSetType parameter to CREATE, you can specify the StackPolicyBody or StackPolicyURL parameter. If you set the ChangeSetType parameter to UPDATE, you can specify only one of the following parameters:

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

The structure that contains the stack policy body. The policy body must be 1 to 16,384 bytes in length. If you set the ChangeSetType parameter to CREATE, you can specify the StackPolicyBody or StackPolicyURL parameter. If you set the ChangeSetType parameter to UPDATE, you can specify only one of the following parameters:

  • StackPolicyBody
  • StackPolicyURL
  • StackPolicyDuringUpdateBody
  • StackPolicyDuringUpdateURL
StackName String No MyStack

The name of the stack for which you want to create the change set.

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

Note This parameter only takes effect when the ChangeSetType parameter is set to CREATE or IMPORT.
UsePreviousParameters Boolean No true

Specifies whether to use the values that you specified last time for the parameters that you do not specify in the request. Default value: false. Valid values:

  • true
  • false
Note This parameter only takes effect when the ChangeSetType parameter is set to UPDATE or IMPORT.
ChangeSetType String No UPDATE

The type of the change set. Default value: UPDATE. Valid values:

  • CREATE: creates a change set for a new stack.
  • UPDATE: creates a change set for an existing stack.
  • IMPORT: creates a change set for a new stack or an existing stack to import resources that are not managed by ROS.

If you create a change set for a new stack, ROS generates a unique stack ID for the stack. The stack is in the REVIEW_IN_PROGRESS state until you execute the change set.

If you want to create a change set for a new stack, do not set the ChangeSetType parameter to UPDATE. If you want to create a change set for an existing stack, do not set the ChangeSetType parameter to CREATE.

Description String No It is a demo.

The description of the change set. The description can be up to 1,024 bytes in length.

RegionId String Yes cn-hangzhou

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

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.

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, for example, oss://ros/template/demo and 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 of the OSS bucket, the value of the RegionId parameter is used.

You can specify only one of the following parameters: TemplateBody, TemplateURL, and TemplateId.

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

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

The URL of the file that contains the stack policy based on which the stack is updated. The URL must point to a policy that is located on an HTTP or HTTPS web server or in an Alibaba Cloud OSS bucket, for example, 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 you do not specify the region of the OSS bucket, the value of the RegionId parameter is used.

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

If you need to update protected resources, specify a temporary overriding stack policy for the resources 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
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 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 following parameters: TemplateBody, TemplateURL, and TemplateId.

TimeoutInMinutes Long No 12

The amount of time that can elapse before the stack enters the CREATE_FAILED or UPDATE_FAILED state.

If you set the ChangeSetType parameter to CREATE, this parameter is required. If you set the ChangeSetType parameter to UPDATE, this parameter is optional.

  • Unit: minutes.
  • Valid values: 10 to 1440.
  • Default value: 60.
DisableRollback Boolean No false

Specifies whether to disable rollback for the stack when the stack fails to be created.

Default value: false. Valid values:

  • true: disables rollback for the stack when the stack fails to be created.
  • false: enables rollback for the stack when the stack fails to be created.
Note This parameter only takes effect when the ChangeSetType parameter is set to CREATE or IMPORT.
ChangeSetName String Yes MyChangeSet

The name of the change set.

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

Note Make sure that the name is unique among all names of change sets that are associated with the specified stack.
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 need to update protected resources, specify a temporary overriding stack policy for the resources during the update. If you do not specify a temporary overriding stack policy, the existing stack 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
RamRoleName String No test-role

The name of the RAM role. ROS assumes the RAM role to create the stack and uses credentials of the role to call the APIs of Alibaba Cloud services.

ROS assumes the RAM role to perform operations on the stack. If you have permissions to perform operations on the stack but you do not have permissions to use the RAM role, ROS still uses the RAM role. You must make sure that the least privileges are granted to the 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 a temporary credential that is generated from the credentials of your account.

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

ReplacementOption String No Disabled

Specifies whether to enable replacement update if a resource property is changed but you cannot change the resource property. For a change, the physical ID of the resource remains unchanged. For a replacement update, the existing resource is deleted, a new resource is created, and the physical ID of the resource is changed. Default value: Disabled. Valid values:

  • Enabled: enables replacement update.
  • Disabled: disables replacement update.
Note Changes have higher priorities than replacement updates. This parameter only takes effect when the ChangeSetType parameter is set to UPDATE.
TemplateId String No 5ecd1e10-b0e9-4389-a565-e4c15efc****

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

You can specify only one of the following parameters: TemplateBody, TemplateURL, and TemplateId.

TemplateVersion String No v1

The version of the template.

Note This parameter only takes effect when the TemplateId parameter is specified.
TemplateScratchId String No 4a6c9851-3b0f-4f5f-b4ca-a14bf691****

The ID of the template that is created for a scenario.

Parallelism Long No 1

The maximum number of concurrent operations that are performed on resources in a Terraform stack. By default, this parameter is empty. You can set this parameter to an integer greater than or equal to 0. If you specify this parameter, ROS associates the value with the stack. The value can affect subsequent operations on the stack.

This parameter only takes effect when the ChangeSetType parameter is set to CREATE or UPDATE.

  • Valid values if you set the ChangeSetType parameter to CREATE:
    • If you set the Parallelism parameter to an integer that is greater than 0, the integer is used.
    • If you set the Parallelism parameter to 0 or do not specify the Parallelism parameter, the default value of Terraform is used. In most cases, the default value of Terraform is 10.
  • Valid values if you set the ChangeSetType parameter to UPDATE:
    • If you set the Parallelism parameter to an integer that is greater than 0, the integer is used.
    • If you set the Parallelism parameter to 0, the default value of Terraform is used. In most cases, the default value of Terraform is 10.
    • If you do not specify the Parallelism parameter, the value that you specified for this parameter in the last operation is used. If you did not specify this parameter in the last operation, the default value of Terraform is used. In most cases, the default value of Terraform is 10.
Parameters.N.ParameterKey String Yes Amount

The name of parameter N that is defined in the template. If you do not specify a name and a value for a parameter, ROS uses the default name and value that are specified in the template. Maximum value of N: 200.

Note The Parameters parameter is optional. If you specify the Parameters parameter, you must specify the Parameters.N.ParameterKey parameter.
Parameters.N.ParameterValue String Yes 12

The value of parameter N that is defined in the template. Maximum value of N: 200.

Note The Parameters parameter is optional. If you specify the Parameters parameter, you must specify the Parameters.N.ParameterValue parameter.
NotificationURLs.N String No http://my-site.com/ros-notify

The callback URL that is used to receive event N for the stack. Valid values:

  • HTTP POST URL

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

  • eventbridge

    When the status of a stack changes, ROS sends event notifications to the EventBridge service. To view the event information, perform the following operations: Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
    Note ROS supports the EventBridge service in the following regions: China (Hangzhou), China (Shanghai), China (Beijing), China (Hong Kong), and China (Zhangjiakou).

Maximum value of N: 5. When the status of a stack changes, ROS sends event notifications. If rollback is enabled for the stack and the stack is in the CREATE_ROLLBACK or ROLLBACK state, ROS sends event notifications. If rollback is enabled for the stack and the stack is in the CREATE_FAILED, UPDATE_FAILED, or IN_PROGRESS state, ROS does not send event notifications.

ROS sends event notifications regardless of whether you specify the parameters in the Outputs section. The following sample code shows the content of an event notification:


{
    "Outputs": [
        {
            "Description": "No description given",
            "OutputKey": "InstanceId",
            "OutputValue": "i-xxx"
        }
    ],
    "StackId": "80bd6b6c-e888-4573-ae3b-93d29113****",
    "StackName": "test-notification-url",
    "Status": "CREATE_COMPLETE"
}
ResourcesToImport.N.ResourceIdentifier String Yes {"VpcId": "vpc-2zevx9ios******"}

The key-value mapping between strings. The mapping is used to identify resource N that you want to import. Set the value of this parameter to a JSON string.

A key is an identifier for a resource and a value is an assignment of data to the key. For example, VpcId is a key that indicates the ID of a virtual private cloud (VPC), and vpc-2zevx9ios**** is a value that is assigned to VpcId. You can call the GetTemplateSummary operation to obtain the key of a resource.

Note This parameter only takes effect when the ChangeSetType parameter is set to IMPORT. The ResourcesToImport parameter is optional. If you specify the ResourcesToImport parameter, you must specify the ResourcesToImport.N.ResourceIdentifier parameter.
ResourcesToImport.N.LogicalResourceId String Yes Vpc

The logical ID of resource N. The logical ID specifies the name of the resource.

Note This parameter only takes effect when the ChangeSetType parameter is set to IMPORT. The ResourcesToImport parameter is optional. If you specify the ResourcesToImport parameter, you must specify the ResourcesToImport.N.LogicalResourceId parameter.
ResourcesToImport.N.ResourceType String Yes ALIYUN::ECS::VPC

The type of resource N. The type must be the same as the type that is defined in the template.

Note This parameter only takes effect when the ChangeSetType parameter is set to IMPORT. The ResourcesToImport parameter is optional. If you specify the ResourcesToImport parameter, you must specify the ResourcesToImport.N.ResourceType parameter.

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

Response parameters

Parameter Type Example Description
ChangeSetId String e85abe0c-6528-43fb-ae93-fdf8de22****

The ID of the change set.

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

http(s)://ros.aliyuncs.com/?Action=CreateChangeSet
&ChangeSetName=MyChangeSet
&StackId=4a6c9851-3b0f-4f5f-b4ca-a14bf691****
&TemplateBody={"ROSTemplateFormatVersion":"2015-09-01"}
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

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

<CreateChangeSetResponse>
    <ChangeSetId>e85abe0c-6528-43fb-ae93-fdf8de22****</ChangeSetId>
    <StackId>4a6c9851-3b0f-4f5f-b4ca-a14bf691****</StackId>
    <RequestId>B288A0BE-D927-4888-B0F7-B35EF84B6E6F</RequestId>
</CreateChangeSetResponse>

JSON format

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

{
  "ChangeSetId" : "e85abe0c-6528-43fb-ae93-fdf8de22****",
  "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 cause of the error.

400

InvalidSchema

{reason}.

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

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 resource property that is defined in a section of 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 cause of the error.

400

StackPolicyValidationFailed

Action denied by stack policy: {reason}.

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

400

StackValidationFailed

{reason}.

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

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 specified for the parameter that is defined in the template. name indicates the parameter name.

404

StackNotFound

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

The error message returned because the 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 stack is being changed. name indicates the stack name or ID. action indicates the change operation.

409

ChangeSetExists

The ChangeSet ({name}) of Stack ({stack}) already exists.

The error message returned because the change set name already exists. name indicates the change set name. stack indicates the name or ID of the stack with which the change set is associated.

409

StackExists

The Stack ({name}) already exists.

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

404

TemplateNotFound

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

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