This topic describes how to use Alibaba Cloud CLI version 3.0.25 or later to call the API operations related to change sets.

CreateChangeSet

You can call this operation to create a change set.

Parameter Type Required Example Description
--Action String Yes CreateChangeSet

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

--ChangeSetName String Yes MyChangeSet

The name of the change set. You must ensure that the name is unique among all change sets associated with a specified stack.

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

--Parameters.N.ParameterKey String No 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 by default.

Maximum value of N: 200.

--Parameters.N.ParameterValue String No 12

The value of parameter N.

Maximum value of N: 200.

--ChangeSetType String No UPDATE

The type of the change set. Valid values: CREATE: creates a change set for a new stack. UPDATE: creates a change set for an existing stack. This is the default value.

If you create a change set for a new stack, ROS creates a stack with a unique stack ID. The stack is 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.

--StackName String No MyStack

The name of the new 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 (_). It must start with a digit or letter.

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

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

The ID of the existing stack for which you want to create the change set. ROS generates the change set by comparing the stack information with the information that you submit, such as a modified template or different inputs.

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

--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 avoid request failures due to excessive length of URLs. You can specify either the TemplateBody parameter or the TemplateURL parameter. But you cannot specify both of them.

--TemplateURL String No oss://ros/template/demo

The URL for 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, such as oss://ros/template/demo and oss://ros/template/demo? RegionId=cn-hangzhou. The template can be up to 524,288 bytes in length.

You can specify either the TemplateBody parameter or the TemplateURL parameter. But you cannot specify both of them.

--TimeoutInMinutes Long No 12

The amount of time that can elapse before the stack status changes to CREATE_FAILED or UPDATE_FAILED.

This parameter is required when the ChangeSetType parameter is set to CREATE. This parameter is optional when the ChangeSetType parameter is set to UPDATE.

Unit: minutes. Valid values: 10 to 1440.

Default value: 60.

--DisableRollback Boolean No false

Specifies whether to disable rollback on stack creation failure. Default value: false. Valid values: true and false. The value true specifies to disable rollback on stack creation failure. The value false specifies to enable rollback on stack creation failure. This parameter takes effect only when the ChangeSetType parameter is set to CREATE.

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

When you set the ChangeSetType parameter to CREATE, you can specify either the StackPolicyBody parameter or the StackPolicyURL parameter. But you cannot specify both of them.

When you set the ChangeSetType parameter to UPDATE, you can specify only one of the following parameters:
  • StackPolicyBody
  • StackPolicyURL
  • StackPolicyDuringUpdateBody
  • StackPolicyDuringUpdateURL
--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 OSS bucket, such as oss://ros/stack-policy/demo, oss://ros/stack-policy/demo? RegionId=cn-hangzhou. The policy can be up to 16,384 bytes in length. If the region of the OSS bucket is not specified, the RegionId parameter value is used by default. The URL can be up to 1,350 bytes in length.

To update protected resources, specify a temporary overriding stack policy during this update. If you do not specify a stack policy, the current policy that is associated with the stack will be 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
--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.

To update protected resources, specify a temporary overriding stack policy during this update. If you do not specify a stack policy, the current policy that is associated with the stack will be 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
--StackPolicyDuringUpdateURL 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 OSS bucket, such as oss://ros/stack-policy/demo, oss://ros/stack-policy/demo? RegionId=cn-hangzhou. The policy can be up to 16,384 bytes in length. If the region of the OSS bucket is not specified, the RegionId parameter value is used by default. The URL can be up to 1,350 bytes in length.

To update protected resources, specify a temporary overriding stack policy during this update. If you do not specify a stack policy, the current policy that is associated with the stack will be 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
--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. This parameter takes effect only when the ChangeSetType parameter is set to UPDATE. Valid values: true and false.

Default value: false.

--NotificationURLs.N RepeatList No http://my-site.com/ros-notify

The callback URL for receiving stack event N. Currently, only HTTP POST requests are supported.

Maximum value of N: 5. The URL can be up to 1,024 bytes in length. Notifications are sent when the status of a stack changes. If the rollback operation is enabled on the stack, the user will not be notified when the stack status changes to CREATE_FAILED or UPDATE_FAILED, but will be notified when the stack status changes to CREATE_ROLLBACK or ROLLBACK. Note that no notifications are sent when a stack is in the IN_PROGRESS state. In other cases, notifications will be sent regardless of whether the Outputs section is defined. The following sample code shows the content of a notification: { "Outputs": [ { "Description": "No description given", "OutputKey": "InstanceId", "OutputValue": "i-xxx" } ], "StackId": "80bd6b6c-e888-4573-ae3b-93d291******", "StackName": "test-notification-url", "Status": "CREATE_COMPLETE"}

--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 ensure that it is unique among different requests. It can only contain letters, digits, hyphens (-), and underscores (_). It can be up to 64 characters in length. For more information, see How to ensure idempotence.

Sample requests

aliyun ros CreateChangeSet --RegionId cn-beijing  --ChangeSetName MyChangeSet --Parameters.1.ParameterKey Amount --Parameters.1.ParameterValue  --TemplateURL oss://ros/template/demo

Sample success responses

{
        "ChangeSetId":"e8dshe0c-6428-46ab-a5g3-fddss6hg****",
        "StackId":"4a6c2547-3v5f-4y7f-bs8a-a14bf639****",
        "RequestId":"9C039DDC-98B2-4668-9FCC-EAE9BAEFDD36"
}

GetChangeSet

You can call this operation to query a change set.

Parameter Type Required Example Description
--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.

--ChangeSetId String Yes 1f6521a4-05af-4975-afe9-bc4b45ad****

The ID of the change set.

--ShowTemplate Boolean No true

Specifies whether to show the template. Default value: false.

Sample requests

aliyun ros GetChangeSet --ChangeSetId 31e744f4-01a5-4015-bded-9560f4b0**** --ShowTemplate true

Sample success responses

{
        "ExecutionStatus":"AVAILABLE",
        "Parameters":[
                {
                        "ParameterValue":"342546988786****",
                        "ParameterKey":"ALIYUN::AccountId"
                },
                {
                        "ParameterValue":"None",
                        "ParameterKey":"ALIYUN::NoValue"
                },
                {
                        "ParameterValue":"cn-beijing",
                        "ParameterKey":"ALIYUN::Region"
                },
                {
                        "ParameterValue":"c18d62d8-51ce-4e8e-b8f6-e00be431****",
                        "ParameterKey":"ALIYUN::StackId"
                },
                {
                        "ParameterValue":"MyStack",
                        "ParameterKey":"ALIYUN::StackName"
                },
                {
                        "ParameterValue":"sg-bfwb3h3eosga1tj5****",
                        "ParameterKey":"SecurityGroupId"
                }
        ],
        "Changes":[
                {
                        "Type":"Resource",
                        "ResourceChange":{
                                "LogicalResourceId":"WebServer",
                                "ResourceType":"ALIYUN::ECS::Instance",
                                "Action":"Add",
                                "Details":[],
                                "Scope":[]
                        }
                }
        ],
        "Description":"It is a demo.",
        "TimeoutInMinutes":12,
        "ChangeSetId":"31e744f4-01a5-4015-bded-9560f4b0****",
        "StackId":"c18d62d8-51ce-4e8e-b8f6-e00be431****",
        "DisableRollback":false,
        "ChangeSetName":"MyChangeSet",
        "ChangeSetType":"CREATE",
        "StackName":"MyStack",
        "Status":"CREATE_COMPLETE",
        "TemplateBody":"{\"ROSTemplateFormatVersion\":\"2015-09-01\",\"Parameters\":{\"SecurityGroupId\":{\"Type\":\"String\"}},\"Resources\":{\"WebServer\":{\"Type\":\"ALIYUN::ECS::Instance\",\"Properties\":{\"ImageId\":\"centos_7\",\"InstanceType\":\"ecs.c6.large\",\"SecurityGroupId\":{\"Ref\":\"SecurityGroupId\"}}}},\"Outputs\":{\"InstanceId\":{\"Value\":{\"Fn:GetAtt\":[\"WebServer\",\"InstanceId\"]}},\"PublicIp\":{\"Value\":{\"Fn:GetAtt\":[\"WebServer\",\"PublicIp\"]}}}}",
        "RequestId":"A46D85A6-9C8E-4603-9989-1FF3F91512F6",
        "RegionId":"cn-beijing",
        "CreateTime":"2019-09-05T14:39:31"
}

DeleteChangeSet

You can call this operation to delete a change set.

Parameter Type Required Example Description
--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.

--ChangeSetId String Yes 1f6521a4-05af-4975-afe9-bc4b45ad****

The ID of the change set.

Sample requests

aliyun ros DeleteChangeSet --ChangeSetId 31e744f4-01a5-4015-bded-9560f4b0****

Sample success responses

{
        "RequestId":"A74B9A63-C40A-41B9-9CCE-E4757E48FFA0"
}

ExecuteChangeSet

You can call this operation to execute a change set.

Parameter Type Required Example Description
--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.

--ChangeSetId String Yes 1f6521a4-05af-4975-afe9-bc4b45ad****

The ID of the change set.

Sample requests

aliyun ros ExecuteChangeSet --ChangeSetId 31e744f4-01a5-4015-bded-9560f4b0****

Sample success responses

{
        "RequestId":"0A46C1A6-6823-43A7-8EF1-D8950DCF29D8"
}

ListChangeSets

You can call this operation to query the list of change sets.

Parameter Type Required Example Description
--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.

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

The ID of the stack.

--ChangeSetName.N RepeatList No MyChangeSet

The name of change set N.

Maximum value of N: 5.

--Status.N RepeatList No CREATE_COMPLETE

The status of change set N. Valid values:

  • CREATE_PENDING
  • CREATE_IN_PROGRESS
  • CREATE_COMPLETE
  • CREATE_FAILED
  • DELETE_FAILED
  • DELETE_COMPLETE

Maximum value of N: 5.

--ExecutionStatus.N RepeatList No AVAILABLE

The execution status of change set N. Valid values:

  • UNAVAILABLE
  • AVAILABLE
  • EXECUTE_IN_PROGRESS
  • EXECUTE_COMPLETE
  • EXECUTE_FAILED
  • OBSOLETE

Maximum value of N: 5.

--PageNumber Long No 1

The number of the page to return. Pages start from page 1.

Default value: 1.

--PageSize Long No 10

The number of entries to return on each page. Valid values: 1 to 50.

Default value: 10.

Sample requests

aliyun ros ListChangeSets --StackId c18d62d8-51ce-4e8e-b8f6-e00be431****

Sample success responses

{
        "PageNumber":1,
        "TotalCount":1,
        "PageSize":10,
        "RequestId":"24AA105D-6AFB-4EBD-923A-DC3A5B10D62A",
        "ChangeSets":[
                {
                        "ExecutionStatus":"AVAILABLE",
                        "Status":"CREATE_COMPLETE",
                        "Description":"It is a demo.",
                        "ChangeSetId":"31e744f4-01a5-4015-bded-9560f4b0****",
                        "StackId":"c18d62d8-51ce-4e8e-b8f6-e00be431****",
                        "RegionId":"cn-beijing",
                        "CreateTime":"2019-09-05T14:39:31",
                        "ChangeSetName":"MyChangeSet",
                        "ChangeSetType":"UPDATE",
                        "StackName":"MyStack"
                }
        ]
}