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 the changes of 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 to update resources that cannot be updated, and whether your account is not granted the required 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 the resources to the original status.
This topic provides an example on how to create a change set. In this example, a change set named MyChangeSet
is created in the China (Hangzhou)
region. The change set is used to change the template body of a stack to {"ROSTemplateFormatVersion":"2015-09-01"}
. The ID of the stack is 4a6c9851-3b0f-4f5f-b4ca-a14bf691****
.
Debugging
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 a changed parameter value, to generate the change set. Note This parameter takes effect only 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 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. Note If you do not specify the region ID 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 | 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:
|
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 takes effect only when the ChangeSetType parameter is set to CREATE or IMPORT. |
UsePreviousParameters | Boolean | No | true | Specifies whether to use the values that specified in the previous request for the parameters that you do not specify in the current request. Default value: false. Valid values:
Note This parameter takes effect only 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:
If you create a change set for a new stack, ROS generates a unique stack ID for the stack. The stack remains in the REVIEW_IN_PROGRESS state until you execute the change set. You cannot use the UPDATE type to create a change set for a new stack or the CREATE type to create a change set for an existing stack. |
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 the value 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 OSS bucket, such as oss://ros/template/demo or 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 ID 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 temporary overriding stack policy. 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 or 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 ID 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 want to update protected resources, specify a temporary overriding stack policy for the resources during the update. If you do not specify the policy, the existing 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:
|
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.
|
DisableRollback | Boolean | No | false | Specifies whether to disable rollback when the stack fails to be created. Default value: false. Valid values:
Note This parameter takes effect only 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 names of all 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 want to update protected resources, specify a temporary overriding stack policy for the resources during the update. If you do not specify the policy, the existing stack 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:
|
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 do not have permissions to use the RAM role, ROS still assumes the RAM role. You must make sure that the least privileges are granted to the RAM role. If you do not specify this parameter, ROS assumes the existing RAM role that is associated with the stack. If no RAM roles are available, 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:
Note Changes have higher priorities than replacement updates. This parameter takes effect only 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 templates 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 takes effect only when the TemplateId parameter is specified. |
Parameters.N.ParameterKey | String | Yes | Amount | The name of parameter N that is defined in the template. If you do not specify the name and value of a parameter, ROS uses the default name and value that are defined in the template. Maximum value of N: 200. Note The Parameters parameter is optional. If you specify Parameters, you must specify Parameters.N.ParameterKey. |
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 Parameters, you must specify Parameters.N.ParameterValue. |
NotificationURLs.N | String | No | http://example.com/ros-notify | The callback URL that is used to receive stack event N. Valid values:
Maximum value of N: 5. When the status of a stack changes, ROS sends an event notification to the specified URL. When rollback is enabled for the stack, event 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 sends event notifications regardless of whether you configure the Outputs section. The following sample code provides an example on the content of an event notification:
|
ResourcesToImport.N.ResourceIdentifier | String | Yes | {"VpcId": "vpc-2zevx9ios******"} | The key-value mapping between strings. The value is a JSON string that identifies resource N to be imported. 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 specifies the ID of a virtual private cloud (VPC), and Note This parameter takes effect only when the ChangeSetType parameter is set to IMPORT. The ResourcesToImport parameter is optional. If you specify ResourcesToImport, you must specify ResourcesToImport.N.ResourceIdentifier. |
ResourcesToImport.N.LogicalResourceId | String | Yes | Vpc | The logical ID of resource N that you want to import. The logical ID specifies the name of a resource that is defined in the template. Note This parameter takes effect only when the ChangeSetType parameter is set to IMPORT. The ResourcesToImport parameter is optional. If you specify ResourcesToImport, you must specify ResourcesToImport.N.LogicalResourceId. |
ResourcesToImport.N.ResourceType | String | Yes | ALIYUN::ECS::VPC | The type of resource N that you want to import. The resource type must be the same as the resource type that is defined in the template. Note This parameter takes effect only when the ChangeSetType parameter is set to IMPORT. The ResourcesToImport parameter is optional. If you specify ResourcesToImport, you must specify ResourcesToImport.N.ResourceType. |
TemplateScratchId | String | No | 4a6c9851-3b0f-4f5f-b4ca-a14bf691**** | The ID of the scenario template. |
Parallelism | Long | No | 1 | 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 when the ChangeSetType parameter is set to CREATE or UPDATE. Valid values:
|
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
&RegionId=cn-hangzhou
&ChangeSetName=MyChangeSet
&Parameters=[{"ParameterKey":"Amount","ParameterValue":"12"}]
&ResourcesToImport=[{"ResourceIdentifier":"{\"VpcId\": \"vpc-2zevx9ios******\"}","LogicalResourceId":"Vpc","ResourceType":"ALIYUN::ECS::VPC"}]
&<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, see Service error codes.
HTTP status code |
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 cause of the error. |
400 |
InvalidSchema |
{reason}. |
The error message returned because the format of the template is invalid. reason indicates the 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 version of the template is invalid. reason indicates the cause of the error. |
400 |
StackPolicyValidationFailed |
Action denied by stack policy: {reason}. |
The error message returned because the operation that is performed to create the change set failed to be validated. reason indicates the cause of the error. |
400 |
StackValidationFailed |
{reason}. |
The error message returned because the stack failed to be validated. reason indicates the 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 name or ID of the stack. |
409 |
ActionInProgress |
Stack {name} already has an action ({action}) in progress. |
The error message returned because the stack is being changed. name indicates the name or ID of the stack. action indicates the change operation. |
409 |
ChangeSetExists |
The ChangeSet ({name}) of Stack ({stack}) already exists. |
The error message returned because a change set that has the same 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 a stack that has the same name already exists. name indicates the stack name. |
404 |
TemplateNotFound |
The Template ({ 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 template version does not exist. ID indicates the template ID. version indicates the template version. |