我在 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"
]
...
但是我illegal char escape
在-Pattern '""'
.
我想在远程机器上执行的命令是: "... FileString.ps1 -Pattern '""' -Replacement '"xyz"' "
PS:用 \ like 转义
"... FileString.ps1 -Pattern '\"\"' -Replacement '\"xyz\"' "
也不起作用。
...
在这里表示省略了不相关的文字。
事实证明,错误消息在指向时具有误导性,-Pattern '""'
因为实际错误转向模板中的另一个位置,其中 Windows 文件路径中的反斜杠没有正确转义(即C:\filename
应该在何时C:\\filename
错误信息需要指向正确的错误位置!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句