Terraform - 从本地将文件复制到现有Azure VM

时间:2018-04-19 08:54:14

标签: azure azure-virtual-machine terraform winrm

这个问题有一个参考。到Connection timeout during file provision to azurerm vm。我不想创建一个已经存在的新VM。我在我的VM中为http激活了WinRM,我可以使用http通过Powershell连接到VM。但是terraform无法使用以下.tf与配置文件

复制文件
resource "null_resource" "test" {
  provisioner "file" {
    source      = "D:/JAISH/TERRAFORM/output.txt"
    destination = "D:/jaish/output.txt"

    connection {
      type     = "winrm"
      user     = "uid"
      password = "pwd"
      host     = "IP"
      port     = "5985"
      timeout  = "20m"
    }
  }
}

如果没有任何状态变化,它总是显示如下。

null_resource.test: Still creating... (18m21s elapsed)
null_resource.test: Still creating... (18m31s elapsed)
null_resource.test: Still creating... (18m41s elapsed)
null_resource.test: Still creating... (18m51s elapsed)
null_resource.test: Still creating... (19m1s elapsed)
null_resource.test: Still creating... (19m11s elapsed)
null_resource.test: Still creating... (19m21s elapsed)

不确定这里有什么问题。

1 个答案:

答案 0 :(得分:0)

WinRM is notoriously slow. Packer/Terraform use the same library to perform communication/file uploads via the WinRM protocol. Very slow. Try archiving the file first file before uploading to squeeze a bit more performance.

You can see an issue on Packers Github here.