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:
-
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.
-
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
-
Log on to the ROS console.
-
In the left-side navigation pane, click Stacks.
-
In the top navigation bar, select the region of your stack. China (Hangzhou) is used in this example.
-
On the Stacks page, find the stack and choose in the Actions column.
-
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.
NoteThe
DeletionPolicyproperty is set toRetain, 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 - AllocationIdTemplate 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, set Stack Name and Change Set Name.
-
Configure the Configure Stack Settings section and click Next.
This example uses default parameter settings. 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 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, find the change set and click Execute in the Actions column.
-
On the Resource tab, verify that EIP2 appears to confirm the import.
References
-
If you no longer need a resource, see Remove a resource from a stack.
-
To detect configuration drift for an imported resource, see Detect the drift status of 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.