Skip to content

Commit 59b255d

Browse files
Update VMSS extension to improve init.ps1 execution
Replaces the use of EncodedCommand with a method that decodes the base64-encoded init.ps1 script and writes it to disk before execution. This change improves script handling and avoids encoding issues.
1 parent a7c54d1 commit 59b255d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gh-runners/vmss.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ resource "azurerm_virtual_machine_scale_set_extension" "vmss" {
102102

103103
# Embed init.ps1 script inline to avoid external dependencies
104104
protected_settings = jsonencode({
105-
commandToExecute = "powershell -ExecutionPolicy Unrestricted -EncodedCommand ${textencodebase64(file("${path.module}/init.ps1"), "UTF-16LE")}"
105+
commandToExecute = "powershell -ExecutionPolicy Unrestricted -Command \"[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64encode(file("${path.module}/init.ps1"))}')) | Set-Content -Path init.ps1 -Encoding UTF8; & .\\init.ps1\""
106106
})
107107
}
108108

0 commit comments

Comments
 (0)