Last active
March 15, 2024 23:05
-
-
Save rybons/54632f51f8dd314221812851e46ae74d to your computer and use it in GitHub Desktop.
null_resource bastion example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "template_file" "windows_script" { | |
template = "${file("${path.module}/templates/windows_script.ps1")}" | |
vars { | |
password = "${var.windows_password}" | |
} | |
} | |
resource "aws_instance" "myinstance" {} | |
resource "null_resource" "provision" { | |
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 ${aws_instance.example.private_ip}" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment