Hi, thank for this it's been very useful. I am trying to use the same method to interpolate variables in Terraform that contain spaces into the powershell 'commandtoexecute'. No combination of double or single quotes or escaping seems to work. For example if I try and pass the following variables to settings in the
azurerm_virtual_machine_extension, I get errors relating to invalid arguments in the commandtoexecute string...
"'RSA#Microsoft Software Key Storage Provider'"
"\\'RSA#Microsoft Software Key Storage Provider\\'"
"''RSA#Microsoft Software Key Storage Provider''"
Settings looks like this:
settings = <<SETTINGS
{
"commandToExecute": "powershell -command \"[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64encode(data.template_file.kickstart.rendered)}')) | Out-File -filepath kickstart-ca.ps1\" && powershell -ExecutionPolicy Unrestricted -File kickstart-ca.ps1 -Encoded_BLOB_SAS_URL ${local.Encoded_BLOB_SAS_URL} -script_directory ${var.script_directory} -next_script ${var.next_script} -ca_num ${var.ca_num} -DomainDnsName ${var.DomainDnsName} -rootca_host_name ${var.rootca_host_name}"
}
SETTINGS
Works fine when variables don't contain spaces! Any suggestions gratefully received 🙂