Skip to content

Instantly share code, notes, and snippets.

@rybons
Last active March 15, 2024 23:06
Show Gist options
  • Save rybons/baa456d4265904d65c1475076fc53834 to your computer and use it in GitHub Desktop.
Save rybons/baa456d4265904d65c1475076fc53834 to your computer and use it in GitHub Desktop.
Sample Terraform winrm connection block
data "template_file" "windows_script" {
template = "${file("${path.module}/templates/windows_script.ps1")}"
vars {
var1 = "${var.var1}"
}
}
resource "aws_instance" "myinstance" {
connection {
type = "winrm"
user = "${var.windows_user}"
password = "${var.windows_password}"
}
[...]
provisioner "file" {
content = "${data.template_file.windows_script.rendered}"
destination = "C:/windows_script.ps1"
}
provisioner "remote-exec" {
inline = [
"powershell.exe C:/windows_script.ps1"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment