您可以根据需要将资源从一个资源栈移动到另外一个资源栈。本文以移动弹性公网IP(EIP)资源为例进行介绍。
背景信息
本示例中,资源栈A中有一个EIP(例如:EIP2),您需要将EIP2移动到资源栈B中。
您可以根据需要将资源从一个资源栈移动到另外一个资源栈。本文以移动弹性公网IP(EIP)资源为例进行介绍。
本示例中,资源栈A中有一个EIP(例如:EIP2),您需要将EIP2移动到资源栈B中。
移除前,资源栈A的模板中包含EIP2。示例模板如下所示:
{
"ROSTemplateFormatVersion": "2015-09-01",
"Resources": {
"Eip": {
"Type": "ALIYUN::VPC::EIP",
"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"
]
}
}
}
}
DeletionPolicy
:取值为Retain
,表示删除保护策略为保留资源。为防止资源被误删除,请务必设置该项。
移除后,资源栈A的模板中不包含EIP2。示例模板如下所示:
{
"ROSTemplateFormatVersion": "2015-09-01",
"Resources": {
"Eip": {
"Type": "ALIYUN::VPC::EIP",
"Properties": {
"Bandwidth": 5
}
}
},
"Outputs": {
"EipAddress": {
"Value": {
"Fn::GetAtt": [
"Eip",
"EipAddress"
]
}
},
"AllocationId": {
"Value": {
"Fn::GetAtt": [
"Eip",
"AllocationId"
]
}
}
}
}
导入前,资源栈B的模板中不包含EIP2。示例模板如下所示:
{
"ROSTemplateFormatVersion": "2015-09-01"
}
导入后,资源栈B的模板中包含EIP2。示例模板如下所示:
{
"ROSTemplateFormatVersion": "2015-09-01",
"Resources": {
"Eip2": {
"Type": "ALIYUN::VPC::EIP",
"DeletionPolicy": "Retain",
"Properties": {
"Bandwidth": 5
}
}
},
"Outputs": {
"EipAddress2": {
"Value": {
"Fn::GetAtt": [
"Eip2",
"EipAddress"
]
}
},
"AllocationId2": {
"Value": {
"Fn::GetAtt": [
"Eip2",
"AllocationId"
]
}
}
}
}
在文档使用中是否遇到以下问题
更多建议
匿名提交