用于将 Azure 存储连接到 VM 的 Terraform 代码不起作用

用于将 Azure 存储连接到 VM 的 Terraform 代码不起作用

我不明白为什么存储帐户没有连接到虚拟机。我没有收到任何错误,存储已创建,但仍未连接到虚拟机。

provider "azurerm" {
  version = "=1.22.0"
 subscription_id = "${var.subscription_id}"
 client_id       = "${var.client_id}"
 client_secret   = "${var.client_secret}"
 tenant_id       = "${var.tenant_id}"
}
....
....
resource "azurerm_storage_account" "st_jh" {
  name                     = "${var.storage_jh}"
  location                 = "westeurope"
  resource_group_name      = "${azurerm_resource_group.rg_main.name}"
  account_tier             = "Standard"
  account_replication_type = "LRS"
        tags {
        environment = "Terraform Staging"
    }
}
.....
.....
resource "azurerm_virtual_machine" "vm1" {
  name                  = "${var.new_vm1_name}"
  location              = "${azurerm_resource_group.rg_main.location}"
  resource_group_name   = "${azurerm_resource_group.rg_main.name}"
  vm_size               = "${var.vm1_size}"
  network_interface_ids = ["${azurerm_network_interface.nic1.id}"]

    boot_diagnostics {
        enabled     = "true"
        storage_uri = "${azurerm_storage_account.st_jh.primary_blob_endpoint}"
    }

  storage_image_reference {
    publisher = "${var.image1_publisher}"
    offer     = "${var.image1_offer}"
    sku       = "${var.image1_sku}"
    version   = "${var.image1_version}"
  }

  storage_os_disk {
    name              = "${var.new_vm1_name}-osdisk"
    managed_disk_type = "Standard_LRS"
    caching           = "ReadWrite"
    create_option     = "FromImage"
  }

  os_profile {
        computer_name  = "${var.Host1}"
        admin_username = "${var.vm1_username}"
    }

    os_profile_linux_config {
        disable_password_authentication = true
        ssh_keys {
            path     = "/home/${var.vm1_username}/.ssh/authorized_keys"
            key_data = "${var.vm1_password}"
        }
    }
}

相关内容