This topic describes how to import an existing resource to a stack. An elastic IP address (EIP) resource is used in the example.
- Obtain the resource identifier property of EIP resources.
For more information, see Obtain a resource identifier property for resource import. This property is required when you edit the template.
For EIP resources, AllocationId is the resource identifier property. It indicates the ID of an EIP.
- Obtain the ID of the EIP.
Log on to the EIP console to obtain the ID of the EIP that you want to import.
- Log on to the ROS console.
- In the left-side navigation pane, click Stacks.
- In the upper-left corner of the page, select the region where the desired stack is
deployed from the drop-down list. Note Make sure that the resource that you want to import resides in the same region as the stack.
- On the Stacks page, find the stack and choose in the Actions column.
- In the Select Template step of the Import Resources wizard, set Template Import Method to Enter Template Content. In the Template Content code editor, add the resource to the template. Then, click Next. In this example, the stack already contains an EIP resource. The resource that you want to import is named EIP2. The following code shows a sample template:
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 - AllocationIdNote The
DeletionPolicyparameter is set to
Retain, which indicates that the resource is retained when it is removed from a stack. To prevent resources from being unexpectedly deleted, we recommend that you set the DeletionPolicy parameter to Retain.
- In the Identify Resources step, enter the resource identifier value such as
eip-bp1s1yz3aja40j377****. Then, click Next.
- In the Configure Template Parameters step, set Stack Name and Change Set Name, and click Next.
- In the Configure Stack step, configure related parameters and click Next. In this example, use the default settings. 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 management page, click Execute in the Actions column that corresponds to the change set to start the resource import.