All Products
Search
Document Center

Resource Orchestration Service:Import an existing resource to update a stack

Last Updated:May 20, 2024

This topic describes how to import an existing resource to update a stack in the Resource Orchestration Service (ROS) console. In the example, an elastic IP address (EIP) is imported.

Scenario

If an empty stack exists in the ROS console or a stack in the ROS console contains cloud resources that you want to manage, you can use resource import to add desired resources to the stack for centralized management.

Prerequisites

Before you import an EIP, make sure that the following operations are complete:

  1. Obtain the resource identifier property of the EIP.

    In this example, AllocationId that specifies the ID of the EIP is obtained. For more information, see Obtain a resource identifier property for resource import.

  2. Obtain the ID of the EIP.

    Log on to the EIP console to obtain the ID of the EIP.

Considerations

You must specify the DeletionPolicy property for the resource that you want to import in the template. If you do not specify this property, the resource fails to be imported. If you specify the DeletionPolicy property, you can choose whether to retain the resource when you delete the stack or remove the resource. 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 the stack you want to manage resides from the region drop-down list. In this example, China (Hangzhou) is selected.

  4. On the Stacks page, find the stack and choose 1 > Import Resources in the Actions column.

  5. In the Select Template step, set the Template Import Method parameter to Enter Template Content. In the Template Content section, modify the template to add the EIP that you want to import. Then, click Next.

    In this example, the stack already contains an EIP. The EIP that you want to import is named EIP2. The following code shows the sample templates before and after the import.

    Note

    In the template content, the DeletionPolicy property is set to Retain. A value of Retain specifies that the system retains the resource. To prevent resources from being unexpectedly deleted, we recommend that you set the DeletionPolicy property to Retain.

    Template before 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

    Template after the import

    ROSTemplateFormatVersion: '2015-09-01'
    Resources:
      Eip:
        Type: ALIYUN::VPC::EIP
        DeletionPolicy: Retain
        Properties:
          Bandwidth: 5
      Eip2:
        Type: ALIYUN::VPC::EIP
        DeletionPolicy: Retain
        Properties:
          Bandwidth: 5
    Outputs:
      EipAddress:
        Value:
          Fn::GetAtt:
            - Eip
            - EipAddress
      AllocationId:
        Value:
          Fn::GetAtt:
            - Eip
            - AllocationId
      EipAddress2:
        Value:
          Fn::GetAtt:
            - Eip2
            - EipAddress
      AllocationId2:
        Value:
          Fn::GetAtt:
            - Eip2
            - AllocationId
  6. In the Configure Parameters step, configure the Stack Name and Change Set Name parameters.

  7. Configure parameters in the Configure Stack Settings section and click Next.

    In this example, the default settings of the parameters are used. For more information, see Create a stack.

  8. In the Identify Resources step, enter the resource identifier value, such as eip-bp1s1yz3aja40j377****, and click Next.

  9. In the Compliance Precheck step, complete the compliance precheck and click Next.

    For more information, see Create a stack.

  10. In the Check and Confirm step, click Create Change Set.

  11. On the Change Sets tab of the stack details page, find the change set and click Execute in the Actions column to start the resource import.

  12. On the Resources tab, check whether EIP2 appears. If EIP2 appears, it is imported.

References

  • You can remove a resource that is no longer needed. For more information, see Remove a resource from a stack.

  • You can check whether the template configurations of the imported resource are matched with the actual configurations. For more information, see Detect drift on a stack.

  • You can call an API operation to update a stack by creating a change set and importing existing resources. For more information, see CreateChangeSet.