Import an existing resource into a new stack for unified management. This topic uses an Elastic IP Address (EIP) as an example.
Scenarios
If you want to manage a large number of cloud resources at the same time, you can use resource import to add the cloud resources to a new stack. This way, you can use the stack to manage the cloud resources in a centralized manner and reduce manual intervention.
Prerequisites
Before you begin, complete the following:
-
Obtain the identifier property of the EIP resource.
In this example, the identifier property of the EIP resource is AllocationId, which is the instance ID of the EIP. For more information, see Obtain the identifier property of a resource to be imported.
-
Obtain the instance ID of the EIP.
Log on to the EIP console and obtain the instance ID of the EIP that you want to import.
Considerations
The resource in the template must include the DeletionPolicy property. Otherwise, the import fails. This property determines whether to retain the resource when its stack is deleted or the resource is removed from the stack. For more information, see DeletionPolicy property.
Procedure
-
Log on to the Resource Orchestration Service (ROS) console.
-
In the left-side navigation pane, click Stacks.
-
In the top navigation bar, select the region where you want to create the stack, such as China (Hangzhou).
-
On the Stacks page, click Import Resources.
-
On the Select Template page, under Specify Template, select Select an Existing Template. Set Template Import Method to Enter Template Content, enter the following YAML template in the Template Content field, and then click Next.
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 - AllocationIdNoteDeletionPolicy: Set the value toRetain. This setting is required to prevent accidental resource deletion. -
On the Configure Parameters page, configure Stack Name and Change Set Name.
-
In the Configure Stack Settings section, configure the parameters and click Next.
This example uses the default configurations. For more information, see Create a stack.
-
On the Identify Resources page, enter the resource identifier, such as
eip-bp140qv3j25nsfaqd****, and click Next. -
On the Compliance Precheck page, complete the compliance precheck and click Next.
For more information about compliance prechecks, see Compliance precheck.
-
On the Check and Confirm page, click Create Stack and Import Change Set.
-
On the Change Sets tab, find the change set and click Run in the Actions column to begin the resource import.
-
On the Stack Information tab, view the status of the stack.
A Status of Import completed. in the Basic information section indicates that the resource was imported successfully.
Related documents
-
To detect configuration drift for an imported resource, see Detect the drift status of a stack.
-
If you no longer need a resource, see Remove a resource from a stack.
-
To import a new resource, see Import existing resources to a stack.
-
To import resources into a new stack by calling an API operation, see CreateChangeSet.