This topic describes how to import an existing resource to create a stack in the Resource Orchestration Service (ROS) console. In the example, an elastic IP address (EIP) is imported.
Scenario
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 import an EIP, make sure that the following operations are complete:
Obtain the resource identifier property of the EIP that you want to import.
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.
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
Log on to the ROS console.
In the left-side navigation pane, click Stacks.
In the top navigation bar, select the region where you want to create a stack from the region drop-down list. For example, you can select China (Hangzhou).
On the Stacks page, click Import Resources.
In the Specify Template section of the Select Template step, select Select an Existing Template. Set the Template Import Method parameter to Enter Template Content. In the Template Content code editor, enter the following YAML template. 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 - AllocationId
NoteIn the template content, the
DeletionPolicy
property is set toRetain
. A value of Retain specifies that the system retains the resource when you delete the stack. To prevent resources from being unexpectedly deleted, we recommend that you set the DeletionPolicy property to Retain.In the Configure Parameters step, configure the Stack Name and Change Set Name parameters.
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.
In the Identify Resources step, enter the resource identifier value, such as
eip-bp140qv3j25nsfaqd****
, and click Next.In the Compliance Precheck step, complete the compliance precheck and click Next.
For more information about the compliance precheck, see Create a stack.
In the Check and Confirm step, click Create Stack and Import Change Set.
On the Change Sets tab of the stack details page, find the change set that you want to manage and click Execute in the Actions column to start the resource import.
On the Stack Information tab, view the status of the stack.
In the Basic Information section on the Stack Information tab, check whether the value of the Status parameter is Created (Resources Imported). If the parameter value is Created (Resources Imported), the resource is imported.
What to do next
Check whether the template configurations and the actual configurations of the imported resource are matched with each other. For more information, see Detect drift on a stack.
Remove a resource that is no longer needed. For more information, see Remove a resource from a stack.
Import an existing resource to update a stack. For more information, see Import an existing resource to update a stack.