All Products
Search
Document Center

Resource Orchestration Service:Move a resource between stacks

Last Updated:Dec 08, 2023

This topic describes how to move a resource from one stack to another stack in the Resource Orchestration Service (ROS) console.

Scenario

A resource can exist in only one stack. If you want to use Stack B to manage a resource that already exists in Stack A, you can remove the resource from Stack A and import the resource to Stack B. When you remove the resource from Stack A, you must use the Retain policy. In this example, an elastic IP address (EIP) is moved from Stack A to Stack B.

Prerequisites

A stack named Stack A that contains an EIP is created. For more information, see ALIYUN::VPC::EIP and Create a stack.

Remove the EIP from Stack A

This section describes how to remove the EIP from Stack A but retain the EIP in ROS. You retain the EIP so that you can import the EIP to Stack B in subsequent operations. If you want to retain a resource in ROS when you remove the resource from a stack, you must set the DeletionPolicy property of the resource to Retain. The DeletionPolicy property specifies the policy based on which a resource is deleted. For more information, see Background information.

Procedure

  1. Log on to the ROS console.

  2. In the left-side navigation pane, click Stacks.

  3. In the top navigation bar, select the region where Stack A resides from the region drop-down list. For example, select China (Hangzhou).

  4. Update the EIP by setting the DeletionPolicy property of the EIP to Retain.

    For more information, see the Step 4 section of the "Remove a resource from a stack" topic.

    If the DeletionPolicy property of the EIP is left empty or set to Delete, you must perform this step. If the DeletionPolicy property of the EIP is set to Retain, you can ignore this step.

  5. Remove the EIP.

    For more information, see the Step 5 section of the "Remove a resource from a stack" topic.

Import the EIP to Stack B

Note

When you import a resource, you must specify the DeletionPolicy property of the resource. If you do not specify the property, the resource fails to be imported.

Import the EIP to Stack B (new stack)

You can import an existing resource to create a stack. In this example, the EIP is imported to create Stack B. For more information, see Use an existing resource to create a stack.

After Stack B is created by using the imported EIP, you can view Stack B on the Stacks page and information about the EIP on the Resources tab of the stack details page in the ROS console.

The following sample code shows a template that you can use to import the EIP to create Stack B:

ROSTemplateFormatVersion: '2015-09-01'
Resources:
  Eip:
    Type: ALIYUN::VPC::EIP
    DeletionPolicy: Retain
    Properties:
      Bandwidth: 5
Outputs:
  EipAddress:
    Value:
      Fn::GetAtt:
        - Eip
        - EipAddress
  AllocationId:
    Value:
      Fn::GetAtt:
        - Eip
        - AllocationId

Import the EIP to Stack B (existing stack)

Prerequisites

A stack named Stack B that does not contain the EIP is created. For more information, see Create a stack.

Procedure

You can import an existing resource to a stack. In this example, the EIP is imported to Stack B. For more information, see Import an existing resource to a stack.

After the EIP is imported to Stack B, you can view information about the EIP on the Resources tab of the stack details page in the ROS console.

The following sample code shows templates before and after the EIP is imported to Stack B. Before the import, the template does not contain the EIP. After the import, the template contains the EIP.

Template before the import

ROSTemplateFormatVersion: '2015-09-01'

Template after the import

ROSTemplateFormatVersion: '2015-09-01'
Resources:
  Eip:
    Type: ALIYUN::VPC::EIP
    DeletionPolicy: Retain
    Properties:
      Bandwidth: 5
Outputs:
  EipAddress:
    Value:
      Fn::GetAtt:
        - Eip
        - EipAddress
  AllocationId:
    Value:
      Fn::GetAtt:
        - Eip
        - AllocationId