Create a stack by using a change set

更新时间:
复制 MD 格式

Change sets help you manage various cloud resources using the resource import feature. This topic describes how to create a stack using a change set.

Scenarios

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. You must use this feature together with the resource import feature. For more information, see Import an existing resource to create a stack. You can use the resource import feature to import cloud resources to create a stack. Then, you can use a change set to preview the creation effect of the resources before the stack takes effect. A stack can manage cloud resources as expected only after you successfully execute the change set on the stack. Before you execute a change set, you can check and modify the stack template to meet your business requirements.

Methods to create a stack using a change set

  • Console: You can use the ROS console to create a stack using a change set.

    To create a stack using a change set in the console, see Create a stack from existing resources.

  • API: You can create a stack by calling change set API operations.

    For more information about the change set API operations, see CreateChangeSet.

  • Alibaba Cloud CLI: You can create a stack using the Alibaba Cloud Command-Line Interface (CLI) and a change set.

    For more information, see the following sections.

Create a stack using the Alibaba Cloud CLI

  1. Install the Alibaba Cloud CLI.

    For more information, see Install Alibaba Cloud CLI.

  2. Configure Alibaba Cloud credentials.

    For more information, see Configure credentials.

  3. Create a stack using a change set.

  4. Create a stack by creating a change set

    Run the aliyun ros CreateChangeSet command to create a stack by creating a change set.

    Set the change set type to CREATE. Specify the stack name, region ID, template, and change set name. For more information, see CreateChangeSet.

    aliyun ros CreateChangeSet --ChangeSetType CREATE --StackName <stack_name> --RegionId <region_id> --TemplateBody <template_body_structure> --ChangeSetName <change_set_name> 

    Create a stack by importing resources

    Run the aliyun ros CreateChangeSet command to create a stack by importing resources.

    Set the change set type to IMPORT. Specify the stack name, region ID, template, the resources to import, and the change set name. For more information, see CreateChangeSet.

    Note
    • You must specify the deletion policy for the resources in the TemplateBody property.

    • You must specify the ResourcesToImport property to complete the resource import.

    aliyun ros CreateChangeSet --ChangeSetType IMPORT --StackName <stack_name> --RegionId <region_id> --TemplateBody <template_body_structure> --ChangeSetName <change_set_name> --ResourcesToImport <resources_to_import>
  5. Run the aliyun ros ExecuteChangeSet command to execute the change set.

    aliyun ros ExecuteChangeSet --ChangeSetId <change_set_id>

References

  • You can view the impacts of a change set on a stack and check the stack template. For more information, see View a change set and Data structures.

  • After you execute a change set on a stack, ROS automatically deletes other change sets that are associated with the stack. For more information, see Execute a change set.

  • If a change set cannot meet your business requirements on a stack update, you can delete the change set. For more information, see Delete a change set.

  • To create a stack by calling an API operation to create a change set, see CreateChangeSet.