我想使用打包器来构建一个 ami。
AMI 最初是由aws_instance
terraform 中的资源构建的。它包含以下内容user_data
<powershell>
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow
netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow
net stop winrm
sc.exe config winrm start=auto
net start winrm
</powershell>
当我将其复制并粘贴到打包器 json 文件中时,打包器不喜欢它:
$ packer build windows-2012.json
Failed to parse template: Error parsing JSON: invalid character '\n' in string literal
At line 22, column 1 (offset 560):
21: "user_data": "<powershell>
22:
我该如何解决?
我转而使用
user_data_file
并将内容放在本地文件中。