Import an existing resource to update a stack

更新时间:
复制 MD 格式

Import an existing resource to a stack in the ROS console. This example uses an elastic IP address (EIP).

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:

  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.

    Obtain the EIP ID from the EIP console.

Considerations

The resource in the template must include the DeletionPolicy property. Otherwise, the import fails. The DeletionPolicy property specifies whether to retain a resource when its stack is deleted or when the resource is removed from the stack. For more information, see DeletionPolicy property.

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 of your stack. China (Hangzhou) is used in this example.

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

  5. In the Select Template step, set Template Import Method to Enter Template Content. In the Template Content section, add the EIP to import, then click Next.

    This example imports EIP2 into a stack that already contains an EIP. The following templates show the content before and after the import.

    Note

    The DeletionPolicy property is set to Retain, which preserves the resource when the stack is deleted. Set this property to prevent accidental resource deletion.

    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, set Stack Name and Change Set Name.

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

    This example uses default parameter settings. 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 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, find the change set and click Execute in the Actions column.

  12. On the Resource tab, verify that EIP2 appears to confirm the import.

References