2

I am using the remote-exec provider in my terraform v0.9.11 template like this:

... 
 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"
     ]
...

But I get an illegal char escape error at -Pattern '""'.

The command I want to execute on the remote machine is: "... FileString.ps1 -Pattern '""' -Replacement '"xyz"' "

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

... represents omitted irrelevant text here.

4

1 回答 1

1

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

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

于 2017-08-24T16:47:04.593 回答