正如你在下面看到的,我正在尝试使用azurerm_managed_disk部署一个新的虚拟机。第一次它工作正常,但每次我运行terraform plan/apply时,azurerm_managed_disk资源都在重建,因此使用此磁盘的VM也在重建。有人知道发生了什么吗?
- 验证码:*
resource "azurerm_snapshot" "snapshot" {
name = "az1srzertosnaphot"
location = azurerm_resource_group.resource_group.location
resource_group_name = azurerm_resource_group.resource_group.name
create_option = "Copy"
source_resource_id = data.azurerm_managed_disk.zerto_managed_disk.id
}
resource "azurerm_managed_disk" "zerto_managed_disk" {
name = "az1srzerto_managed_disk"
location = azurerm_resource_group.resource_group.location
resource_group_name = azurerm_resource_group.resource_group.name
storage_account_type = "Standard_LRS"
create_option = "Copy"
source_resource_id = azurerm_snapshot.snapshot.id
disk_size_gb = "127"
}
resource "azurerm_virtual_machine" "zerto_virtual_machine" {
name = var.vm_zerto_name
location = azurerm_resource_group.resource_group.location
resource_group_name = azurerm_resource_group.resource_group.name
vm_size = "Standard_D2s_v3"
network_interface_ids = [azurerm_network_interface.vm_zerto_interface.id]
storage_os_disk {
name = azurerm_managed_disk.zerto_managed_disk.name
caching = "ReadWrite"
disk_size_gb = "127"
os_type = "Windows"
managed_disk_type = "Standard_LRS"
managed_disk_id = azurerm_managed_disk.zerto_managed_disk.id
create_option = "Attach"
}
os_profile_windows_config {
provision_vm_agent = false
字符串
- 按照地形图 *
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# module.disaster_recovery.azurerm_managed_disk.zerto_managed_disk must be replaced
-/+ resource "azurerm_managed_disk" "zerto_managed_disk" {
~ disk_iops_read_only = 0 -> (known after apply)
~ disk_iops_read_write = 500 -> (known after apply)
~ disk_mbps_read_only = 0 -> (known after apply)
~ disk_mbps_read_write = 60 -> (known after apply)
- hyper_v_generation = "V1" -> null # forces replacement
~ id = "/subscriptions/XXXXXXXXXXXX/resourceGroups/az-prd-euw-disasterrecovery-rg-001/providers/Microsoft.Compute/disks/az1srzerto_managed_disk" -> (known after apply)
+ logical_sector_size = (known after apply)
~ max_shares = 0 -> (known after apply)
name = "az1srzerto_managed_disk"
- on_demand_bursting_enabled = false -> null
- os_type = "Windows" -> null
+ source_uri = (known after apply)
- tags = {} -> null
+ tier = (known after apply)
- trusted_launch_enabled = false -> null
# (7 unchanged attributes hidden)
}
# module.disaster_recovery.azurerm_virtual_machine.zerto_virtual_machine must be replaced
-/+ resource "azurerm_virtual_machine" "zerto_virtual_machine" {
+ availability_set_id = (known after apply)
~ id = "/subscriptions/XXXXXXXXXX/resourceGroups/az-prd-euw-disasterrecovery-rg-001/providers/Microsoft.Compute/virtualMachines/az1srzerto" -> (known after apply)
+ license_type = (known after apply)
name = "az1srzerto"
- tags = {} -> null
- zones = [] -> null
# (6 unchanged attributes hidden)
+ identity {
+ identity_ids = (known after apply)
+ principal_id = (known after apply)
+ type = (known after apply)
}
+ storage_data_disk {
+ caching = (known after apply)
+ create_option = (known after apply)
+ disk_size_gb = (known after apply)
+ lun = (known after apply)
+ managed_disk_id = (known after apply)
+ managed_disk_type = (known after apply)
+ name = (known after apply)
+ vhd_uri = (known after apply)
+ write_accelerator_enabled = (known after apply)
}
+ storage_image_reference {
+ id = (known after apply)
+ offer = (known after apply)
+ publisher = (known after apply)
+ sku = (known after apply)
+ version = (known after apply)
}
~ storage_os_disk {
~ managed_disk_id = "/subscriptions/XXXXXXXXXX/resourceGroups/az-prd-euw-disasterrecovery-rg-001/providers/Microsoft.Compute/disks/az1srzerto_managed_disk" -> (known after apply) # forces replacement
name = "az1srzerto_managed_disk"
# (6 unchanged attributes hidden)
}
# (1 unchanged block hidden)
}
Plan: 2 to add, 0 to change, 2 to destroy.
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.
型
你知道吗?
1条答案
按热度按时间mxg2im7a1#
我们也尝试过使用terraform通过托管磁盘和快照来创建虚拟机。
正如@Marko E 所建议的,* 我们也观察到了使用不同参数的相同情况(即,create_option=“Empty”并将其更改为“copy”)*。
下面是我们正在使用的代码。
字符串
型
的