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
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.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
ros:CreateChangeSet | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
StackId | string | No | 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. Note
This parameter takes effect only when ChangeSetType is set to UPDATE or IMPORT.
| 4a6c9851-3b0f-4f5f-b4ca-a14bf691**** |
StackPolicyURL | string | No | 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:
| oss://ros/stack-policy/demo |
StackPolicyBody | string | No | 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:
| {"Statement":[{"Effect":"Allow","Action":"Update:*","Principal":"*","Resource":"*"}]} |
StackName | string | No | The name of the stack for which you want to create the change set. Note
This parameter takes effect only if you set ChangeSetType to CREATE or IMPORT.
| MyStack |
UsePreviousParameters | boolean | No | 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:
Note
This parameter takes effect only if you set ChangeSetType to UPDATE or IMPORT.
| true |
ChangeSetType | string | No | The type of the change set. Valid values:
If you set ChangeSetType to CREATE, ROS creates a stack. The stack remains in the Note
| UPDATE |
Description | string | No | The description of the change set. The description can be up to 1,024 bytes in length. | It is a demo. |
RegionId | string | Yes | The region ID of the change set. You can call the DescribeRegions operation to query the most recent region list. | cn-hangzhou |
ClientToken | string | No | 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. | 123e4567-e89b-12d3-a456-42665544**** |
TemplateURL | string | No | 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 |
StackPolicyDuringUpdateURL | string | No | 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.
| oss://ros/stack-policy/demo |
TemplateBody | string | No | 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"} |
TimeoutInMinutes | long | No | The amount of time that can elapse before the stack enters the CREATE_FAILED or UPDATE_FAILED state.
| 12 |
DisableRollback | boolean | No | Specifies whether to disable rollback when the stack fails to be created.
Note
This parameter takes effect only if you set ChangeSetType to CREATE or IMPORT.
| false |
ChangeSetName | string | Yes | The name of the change set. Note
Make sure that the name is unique among all names of change sets that are associated with the specified stack.
| MyChangeSet |
StackPolicyDuringUpdateBody | string | No | The structure of the temporary overriding stack policy. The policy body must be 1 to 16,384 bytes in length.
| {"Statement":[{"Effect":"Allow","Action":"Update:*","Principal":"*","Resource":"*"}]} |
RamRoleName | string | No | 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. For more information about RAM roles, see Use a stack role. | test-role |
ReplacementOption | string | No | 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:
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 |
TemplateId | string | No | 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**** |
TemplateVersion | string | No | The version of the template. Note
This parameter takes effect only if you specify TemplateId.
| v1 |
Parameters | array<object> | No | The parameters that are defined in the template. | |
object | No | |||
ParameterKey | string | Yes | 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 |
ParameterValue | string | Yes | 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 |
NotificationURLs | array | No | The callback URLs that are used to receive stack events. | |
string | No | The callback URL that is used to receive stack events. Valid values:
Each URL can be up to 1,024 bytes in length.
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.
| http://example.com/ros-notify | |
ResourcesToImport | array<object> | No | The resources that you want to import to the stack. | |
object | No | |||
ResourceIdentifier | string | No | 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. 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******"} |
LogicalResourceId | string | No | 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 |
ResourceType | string | No | 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 |
TemplateScratchId | string | No | 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**** |
Parallelism | long | No | 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.
| 1 |
For more information about common request parameters, see Common parameters.
Response parameters
Examples
Sample success responses
JSON
format
{
"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 time | Summary of changes | Operation |
---|---|---|
2024-01-11 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
2023-08-15 | The internal configuration of the API is changed, but the call is not affected | View Change Details |