如何在 terraform 中转义双引号?

how to escape double quotation in terraform?

我在我的 terraform v0.9.11 模板中使用 remote-exec 提供程序,如下所示:

... 
 provisioner "remote-exec" {
     inline = [
       "Set-ExecutionPolicy Bypass -force",
       "./C:\ProgramData\Amazon\EC2-Windows\Launch\Config\Replace-FileString.ps1 -Pattern '""' -Replacement '"${var.admin_password}"' -Path LauchConfig.json"
     ]
...

但我在 -Pattern '""' 处收到 illegal char escape 错误。

我要在远程机器上执行的命令是:"... FileString.ps1 -Pattern '""' -Replacement '"xyz"' "

PS: escaping with \ like "... FileString.ps1 -Pattern '\"\"' -Replacement '\"xyz\"' " does not work either.

... represents omitted irrelevant text here.

事实证明,错误消息在指向 -Pattern '""' 时具有误导性,因为实际错误发生在模板中的另一个位置,其中 windows 文件路径中的反斜杠不正确转义(即 C:\filename 应该是 C:\filename

错误信息需要指向正确的错误位置!