I'm trying to use provisioner "file" to copy a local file onto a Windows Azure VM after creating it using Terraform.
I have enabled the custom script extension using:
resource "azurerm_virtual_machine_extension" "VM" {
name = "WinRM"
location = "${azurerm_resource_group.VM.location}"
resource_group_name = "${azurerm_resource_group.VM.name}"
virtual_machine_name = "${azurerm_virtual_machine.VM01.name}"
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.8"
I have port 5985 open in my NSG:
security_rule {
name = "AllowWinRM"
priority = 300
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "5985"
source_address_prefix = "*"
destination_address_prefix = "*"
}
My OS config is set to:
os_profile_windows_config {
provision_vm_agent = true
winrm {
protocol="http"
}
}
Finally I try to copy the file:
resource "null_resource" "VM" {
provisioner "file" {
source = "output.txt"
destination = "c:\\temp\\output.txt"
connection {
type = "winrm"
user = "${var.adminusername}"
password = "${var.adminpassword}"
host = "${azurerm_public_ip.VM1_pip.ip_address}"
port = "5985"
timeout = "20m"
}
}
}
Every time I try to 'apply' this it hits the 20 minute timeout and fails with the following error (public ip removed):
azurerm_virtual_machine_extension.VM: compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Code="" Message="" * null_resource.buildagent: timeout - last error: unknown error Post http://PublicIP:5985/wsman: dial tcp PublicIP:5985: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
First of all, am I doing this correctly? Everything seems to be set up correctly but that last step keeps failing.