Jaish Mathews
Jaish Mathews

Reputation: 864

Connection timeout during file provision to azurerm vm

I am getting below timeout message once trying to provision file to an azure RM VM .

unknown error Post http://terraform.eastus.cloudapp.azure.com:3389/wsman: read tcp 192.168.0.4:59745->52.224.162.240:3389: wsarecv: An existing connection was forcibly closed by the remote host.

I am trying file provision and the VM already there and no need to create it. I only need to copy a text file to an existing VM using below config.

provider "azurerm"
{
}
resource "null_resource" "test"
{

provisioner "file" 
{
        connection 
        {
            type = "winrm"
            user = ""
            password = ""
            host="terraform.eastus.cloudapp.azure.com"
            port="3389"
            timeout = "20m"
        }
    source = "D:\\jaish\\output.txt"
    destination = "D:\\output.txt"

}
}

Upvotes: 0

Views: 1157

Answers (2)

Shui shengbao
Shui shengbao

Reputation: 19195

You could check official document(Provisioner Connections) in this link.

Additional arguments only supported by the winrm connection type:

https - Set to true to connect using HTTPS instead of HTTP.

Now, you use connection type is winrm, so you need open port 5986 on VM's firewall and Azure NSG. You also need create a self-signed certificate. You could check this blog to do this.


Another solution, you could use Azure Custom Script to do this. You could create a script to download file from Azure Storage account or github.

Using terraform to do this, you could check this answer.

Upvotes: 2

phydeauxman
phydeauxman

Reputation: 1712

I have not tried this approach before but the first thing that draws my attention is that you are using a type of winrm with a port of 3389. 3389 is used for RDP and the default winrm ports are 5985 (HTTP) and 5986 (HTTPS).

Upvotes: 2

Related Questions