Skip to content

Commit ca29f18

Browse files
committed
terraform: fix Windows password injection in userdata_windows.tpl
Use single quotes for the SetPassword argument so PowerShell treats the injected value literally. With double quotes, any $-containing password (e.g. 'Io4$$WZy...') gets corrupted by PowerShell variable expansion ($$ → PID, $WZy → empty var), causing the Windows instance to boot with a different password than Launchpad holds → WinRM 401. Terraform templatefile() substitutes ${windows_administrator_password} before userdata reaches EC2, so single-quoting is safe: Terraform sees and expands the ${} expression; PowerShell then receives the literal value with no further interpretation.
1 parent c2f274d commit ca29f18

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

examples/terraform/aws-simple/userdata_windows.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<powershell>
22
$admin = [adsi]("WinNT://./administrator, user")
3-
$admin.psbase.invoke("SetPassword", "${windows_administrator_password}")
3+
$admin.psbase.invoke("SetPassword", '${windows_administrator_password}')
44

55
# Snippet to enable WinRM over HTTPS with a self-signed certificate
66
# from https://gist.github.com/TechIsCool/d65017b8427cfa49d579a6d7b6e03c93

0 commit comments

Comments
 (0)