terraform - 使用网络接口安全组从 AzureRM v1 迁移到 v2 时遇到问题,无法应用
问题描述
我正在将我的配置从 azurerm 1.44 迁移到 2.3.0,并且需要使用新的配置项 azurerm_network_interface_security_group_association
当我做我的计划时,一切似乎都很好:
Terraform 将执行以下操作:
# module.web-msg.azurerm_network_interface_security_group_association.main[0] will be created
+ resource "azurerm_network_interface_security_group_association" "main" {
+ id = (known after apply)
+ network_interface_id = "/subscriptions/xxxx/resourceGroups/vm-0/providers/Microsoft.Network/networkInterfaces/vm-0-nic"
+ network_security_group_id = "/subscriptions/xxxx/resourceGroups/vm-0/providers/Microsoft.Network/networkSecurityGroups/MsgHubNetworkSecurityGroup"
}
# module.web-msg.azurerm_network_interface_security_group_association.main[1] will be created
+ resource "azurerm_network_interface_security_group_association" "main" {
+ id = (known after apply)
+ network_interface_id = "/subscriptions/xxxx/resourceGroups/vm-1/providers/Microsoft.Network/networkInterfaces/vm-1-nic"
+ network_security_group_id = "/subscriptions/xxxx/resourceGroups/vm-1/providers/Microsoft.Network/networkSecurityGroups/MsgHubNetworkSecurityGroup"
}
但是当我申请时,我得到了这没有意义,因为资源“vm-0”是由 terraform 管理的。
terraform apply .\the.plan
module.web-msg.azurerm_network_interface_security_group_association.main[0]: Creating...
module.web-msg.azurerm_network_interface_security_group_association.main[1]: Creating...
Error: A resource with the ID "vm-0" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_network_interface_security_group_association" for more information.
on ..\..\..\infra\terraform\global\msghub\main.tf line 52, in resource "azurerm_network_interface_security_group_association" "main":
52: resource "azurerm_network_interface_security_group_association" "main" {
Error: A resource with the ID "vm-1" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_network_interface_security_group_association" for more information.
on ..\..\..\infra\terraform\global\msghub\main.tf line 52, in resource "azurerm_network_interface_security_group_association" "main":
52: resource "azurerm_network_interface_security_group_association" "main" {
解决方案
推荐阅读
- oracle - Oracle 数据库的代理 SQL
- yii2 - 如何延迟 yii2-queue 任务,直到所有先前的任务都完成?
- excel - 向下扫描一列,直到您点击文本,然后粘贴第一行和最后一行的编号
- excel - 如何复制相对于我的活动单元格的一系列单元格?
- swift - 通过进程运行脚本 - 找不到脚本
- c# - 字符串数组 GetLength(1) 工作替代
- python - 如何使用python在文件中有效地存储多个浮点数组
- c# - 使用 SSIS 包和脚本任务执行具有多个子报表的 SSRS 报表
- java - JavaFX + SQL:为 SQL 数据库的每一行添加 1 个带有 3 个 ComboBox 的新 HBox
- reactjs - 在 React 中使用下拉按钮