connection {
type = "winrm"
user = "testadmin"
password = "Password1234!"
host = azurerm_public_ip.example.ip_address
} provisioner "remote-exec" {
script = "C:\\Proj\\Fali\\vm\\DC.ps1"
}
I have opened all the ports
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
Connection timeout during running a PS Script, Mentioned is code snippet
One of the workaround to resolve the above issue;
You can use the below format in your example.tf
file by provisioning the file name and provide the timeout value to it .
connection {
host = azurerm_public_ip.win_pubip.fqdn
type = "winrm"
port = 5985
https = false
timeout = "2m"
user = var.username
password = var.password
}
provisioner "file" {
source = "files/yourfile.ps1"
destination = "c:/terraform/yourfile.ps1"
}
provisioner "remote-exec" {
inline = [
"PowerShell.exe -ExecutionPolicy Bypass c:\\terraform\\yourfile.ps1",
]
For complete information how to provision and execute the configuration script,please refer this
And for more information please refer the below links:-