All Products
Search
Document Center

Resource Orchestration Service:CreateChangeSet

Last Updated:Sep 12, 2024

Creates a change set for a stack. You can view proposed changes before you execute the change set.

Operation description

Scenarios

Use a change set to create a stack

If you want to manage a large number of cloud resources and preview the creation effect of the resources before a stack that contains the resources is created, you can create the stack by using a change set. In this case, you must set ChangeSetType to CREATE and configure the relevant parameters. For more information about change sets, see Change set.

Use a change set to update a stack

If you want to preview the impacts of changes to an existing stack before you update the stack resources, you can create a change set for the stack. In this case, you must set ChangeSetType to UPDATE and configure the relevant parameters. For more information about change sets, see Change set.

Use a change set and existing resources to create a stack

If you want to add existing cloud resources to a new stack for centralized management, you can use a change set to create a stack and import the resources to the stack. In this case, you must set ChangeSetType to IMPORT and configure the relevant parameters. For more information about the resource import feature, see Overview .

Use a change set and existing resources to update a stack

If you want to import existing resources to an existing stack for centralized management, you can use a change set to update the stack. In this case, you must set ChangeSetType to IMPORT and configure the relevant parameters. For more information about the resource import feature, see Overview .

Limits

  • You can use change sets to update only stacks that are in specific states. For more information, see Use a change set to update a stack.
  • A stack can have up to 20 change sets.
  • Change sets reflect only the changes to stacks. Change sets do not reflect whether stacks can be successfully updated.
  • A change set does not check if you exceed an account limit, if you update resources that cannot be updated, or if you have insufficient permissions to modify resources, all of which can cause a stack update to fail. If a stack update fails, Resource Orchestration Service (ROS) attempts to roll back your resources to their original status.

This topic provides an example on how to use a change set to update a stack. In this example, a change set named MyChangeSet is created in the China (Hangzhou) region. The template of a stack whose ID is 4a6c9851-3b0f-4f5f-b4ca-a14bf691**** 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.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ros:CreateChangeSetcreate
  • Stack
    acs:ros:{#regionId}:{#accountId}:stack/{#StackId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
StackIdstringNo

The ID of the stack for which you want to create the change set. ROS compares the stack information with the information that you submit, such as an updated template or parameter value, to generate the change set.
You can call the ListStacks operation to query the stack ID.

Note This parameter takes effect only when ChangeSetType is set to UPDATE or IMPORT.
4a6c9851-3b0f-4f5f-b4ca-a14bf691****
StackPolicyURLstringNo

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 Object Storage Service (OSS) bucket, such as oss://ros/stack-policy/demo or oss://ros/stack-policy/demo?RegionId=cn-hangzhou. The policy file can be up to 16,384 bytes in length.

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

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

If you set ChangeSetType to CREATE, you can specify StackPolicyBody or StackPolicyURL.

If you set ChangeSetType to UPDATE, you can specify only one of the following parameters:

  • StackPolicyBody
  • StackPolicyURL
  • StackPolicyDuringUpdateBody
  • StackPolicyDuringUpdateURL
oss://ros/stack-policy/demo
StackPolicyBodystringNo

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

If you set ChangeSetType to CREATE, you can specify StackPolicyBody or StackPolicyURL.

If you set ChangeSetType to UPDATE, you can specify only one of the following parameters:

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

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 a letter.

Note This parameter takes effect only if you set ChangeSetType to CREATE or IMPORT.
MyStack
UsePreviousParametersbooleanNo

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
  • false (default)
Note This parameter takes effect only if you set ChangeSetType to UPDATE or IMPORT.
true
ChangeSetTypestringNo

The type of the change set. Valid values:

  • CREATE: creates a change set for a new stack.
  • UPDATE (default): 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 set ChangeSetType to CREATE, ROS creates a stack. The stack remains in the REVIEW_IN_PROGRESS state until you execute the change set.

Note
  • You cannot set ChangeSetType to UPDATE when you create a change set for a new stack. You cannot set ChangeSetType to CREATE when you create a change set for an existing stack.

  • If you set ChangeSetType to Import, you cannot configure a stack policy. You can specify ChangeSetType only when you create or update a stack.

UPDATE
DescriptionstringNo

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

It is a demo.
RegionIdstringYes

The region ID of the change set.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
ClientTokenstringNo

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 contain letters, digits, hyphens (-), and underscores (_) and cannot exceed 64 characters in length.
For more information, see How to ensure idempotence.

123e4567-e89b-12d3-a456-42665544****
TemplateURLstringNo

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 OSS bucket, such as 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 RegionId 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.

oss://ros/template/demo
StackPolicyDuringUpdateURLstringNo

The URL of 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 OSS bucket, such as 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 RegionId 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 takes effect only if you set ChangeSetType to UPDATE. You can specify only one of the following parameters:

  • StackPolicyBody
  • StackPolicyURL
  • StackPolicyDuringUpdateBody
  • StackPolicyDuringUpdateURL
oss://ros/stack-policy/demo
TemplateBodystringNo

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.

Note You must and can specify only one of the following parameters: TemplateBody, TemplateURL, and TemplateId.
{"ROSTemplateFormatVersion":"2015-09-01"}
TimeoutInMinuteslongNo

The amount of time that can elapse before the stack enters the CREATE_FAILED or UPDATE_FAILED state.
If you set ChangeSetType to CREATE, this parameter is required. If you set ChangeSetType to UPDATE, this parameter is optional.

  • Unit: minutes.
  • Valid values: 10 to 1440.
  • Default value: 60.
12
DisableRollbackbooleanNo

Specifies whether to disable rollback when the stack fails to be created.
Valid values:

  • true: disables rollback for the stack when the stack fails to be created.
  • false (default): enables rollback for the stack when the stack fails to be created.
Note This parameter takes effect only if you set ChangeSetType to CREATE or IMPORT.
false
ChangeSetNamestringYes

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 a letter.

Note Make sure that the name is unique among all names of change sets that are associated with the specified stack.
MyChangeSet
StackPolicyDuringUpdateBodystringNo

The structure 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 takes effect only if you set ChangeSetType to UPDATE. You can specify only one of the following parameters:

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

The name of the Resource Access Management (RAM) role. ROS assumes the RAM role to create the stack and uses the 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, ROS assumes the RAM role even if you do not have permissions to use the RAM role. You must make sure that permissions are granted to the RAM role based on the principle of least privilege.
If you do not specify this parameter, ROS assumes the existing role of the stack. If no roles are available, ROS uses a temporary credential that is generated from the credentials of your account.
The RAM role name can be up to 64 characters in length.

For more information about RAM roles, see Use a stack role.

test-role
ReplacementOptionstringNo

Specifies whether to enable replacement update if a resource property is changed and you cannot modify the new 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. Valid values:

  • Enabled
  • Disabled (default)
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. This parameter takes effect only if you set ChangeSetType to UPDATE.
Disabled
TemplateIdstringNo

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

You can call the ListTemplates operation to query the template ID.

Note You can specify only one of the following parameters: TemplateBody, TemplateURL, and TemplateId.
5ecd1e10-b0e9-4389-a565-e4c15efc****
TemplateVersionstringNo

The version of the template.

Note This parameter takes effect only if you specify TemplateId.
v1
Parametersarray<object>No

The parameters that are defined in the template.

objectNo
ParameterKeystringYes

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

Note Parameters is optional. If you specify Parameters, you must also specify Parameters.N.ParameterKey.
Amount
ParameterValuestringYes

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

Note Parameters is optional. If you specify Parameters, you must also specify Parameters.N.ParameterValue.
12
NotificationURLsarrayNo

The callback URLs that are used to receive stack events.

stringNo

The callback URL that is used to receive stack events. 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 an event notification 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 This feature is supported in the China (Hangzhou), China (Shanghai), China (Beijing), China (Hong Kong), and China (Zhangjiakou) regions.

You can specify up to five callback URLs. When the status of a stack changes, ROS sends a notification to the specified URL. When rollback is enabled for the stack, notifications are sent if the stack is in the CREATE_ROLLBACK or ROLLBACK state, but are not sent if the stack is in the CREATE_FAILED, UPDATE_FAILED, or IN_PROGRESS state. ROS does not send notifications when the stack is in the IN_PROGRESS state.
ROS sends notifications regardless of whether you specify the Outputs section. The following sample code provides an example on the content of a notification:

{
   "Outputs": [
       {
           "Description": "No description given",
           "OutputKey": "InstanceId",
           "OutputValue": "i-xxx"
       }
   ],
   "StackId": "80bd6b6c-e888-4573-ae3b-93d29113****",
   "StackName": "test-notification-url",
   "Status": "CREATE_COMPLETE"
}
http://example.com/ros-notify
ResourcesToImportarray<object>No

The resources that you want to import to the stack.

objectNo
ResourceIdentifierstringNo

The key-value mapping between strings. The key-value mapping is used to identify resource N that you want to import. The key-value mapping must be a JSON string.
A key is an identifier property of a resource and a value is the property value. For example, the key of the ALIYUN::ECS::VPC resource is VpcId and the value is vpc-2zevx9ios****.

You can call the GetTemplateSummary operation to query the identifier property of the resource.

Note This parameter takes effect only when ChangeSetType is set to IMPORT. ResourcesToImport is optional. If you specify ResourcesToImport, you must specify ResourcesToImport.N.ResourceIdentifier.
{"VpcId": "vpc-2zevx9ios******"}
LogicalResourceIdstringNo

The logical ID of resource N. The logical ID is the name of the resource defined in the template.

Note This parameter takes effect only when ChangeSetType is set to IMPORT. ResourcesToImport is optional. If you specify ResourcesToImport, you must specify ResourcesToImport.N.LogicalResourceId.
Vpc
ResourceTypestringNo

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

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

The ID of the resource scenario. In this example, this parameter specifies the ID of a resource management scenario.

This parameter takes effect only when ChangeSetType is set to IMPORT. TemplateScratchId is supported only when you import resources to create a new stack.

If you want to use a resource management scenario to import resources, you can specify only TemplateScratchId rather than configuring parameters related to templates.

You can call the ListTemplateScratches operation to query the ID of the resource management scenario.

4a6c9851-3b0f-4f5f-b4ca-a14bf691****
ParallelismlongNo

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

This parameter takes effect only if you set ChangeSetType to CREATE or UPDATE.

  • Valid values for change sets of the CREATE type:

    • If you set this parameter to an integer that is greater than 0, the integer is used.
    • If you set this parameter to 0 or leave this parameter empty, no limit is imposed on ROS stacks. However, the default value in Terraform is used for Terraform stacks. In most cases, the default value in Terraform is 10.
  • Valid values for change sets of the UPDATE type:

    • If you set this parameter to an integer that is greater than 0, the integer is used.
    • If you set this parameter to 0, no limit is imposed on ROS stacks. However, the default value in Terraform is used for Terraform stacks. In most cases, the default value in Terraform is 10.
    • If you leave this parameter empty, the value that you specified for this parameter in the previous request is used. If you left this parameter empty in the previous request, no limit is imposed on ROS stacks. However, the default value in Terraform is used for Terraform stacks. In most cases, the default value in Terraform is 10.
1

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

Response parameters

ParameterTypeDescriptionExample
object
ChangeSetIdstring

The ID of the change set.

e85abe0c-6528-43fb-ae93-fdf8de22****
RequestIdstring

The ID of the request.

B288A0BE-D927-4888-B0F7-B35EF84B6E6F
StackIdstring

The ID of the stack.

4a6c9851-3b0f-4f5f-b4ca-a14bf691****

Examples

Sample success responses

JSONformat

{
  "ChangeSetId": "e85abe0c-6528-43fb-ae93-fdf8de22****",
  "RequestId": "B288A0BE-D927-4888-B0F7-B35EF84B6E6F",
  "StackId": "4a6c9851-3b0f-4f5f-b4ca-a14bf691****"
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-01-11The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-08-15The internal configuration of the API is changed, but the call is not affectedView Change Details