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:
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 the stack you want to manage resides from the region drop-down list. For example, you can select China (Hangzhou).
On the Stacks page, find the stack and choose
in the Actions column.In the Select Template step, set the Template Import Method parameter to Enter Template Content. In the Template Content code editor, 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.
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.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
In the Configure Parameters step, configure the Stack Name and Change Set Name parameters and the parameters in the Configure Template Parameters section.
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-bp1s1yz3aja40j377****
, and click Next.In the Compliance Precheck step, complete the compliance precheck and click Next.
For more information, see Create a stack.
In the Check and Confirm step, click Create 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 Resources tab, check whether EIP2 appears. If EIP2 appears, it is imported.
What to do next
Remove a resource that is no longer needed. For more information, see Remove a resource from a stack.
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.