I'm trying to figure out the proper way to pass terraform variable value to my Powershell script.
The script fails when I try to deploy it using Microsoft extension. Below is my terraform script:
resource "azurerm_virtual_machine_extension" "test" {
name = "testt"
virtual_machine_id = azurerm_virtual_machine.example.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
protected_settings = <<SETTINGS
{
"commandToExecute": "powershell -command \"[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64encode(file("shell.ps1"))}')) | Out-File -filepath shell.ps1\" && powershell -ExecutionPolicy Unrestricted -File shell.ps1 -value1 ${var.value1} -value2 ${var.value2}"
}
SETTINGS
}
Below is the Powershell script:
param(
[string]$value1,
[string]$value2
)
The error I am facing:
"message": "param : The term 'param' is not recognized as the name of a cmdlet, function, script file, or operable program. Check \r\nthe spelling of the name, or if a path was included, verify that the path is correct and try again.