我想使用packer来构建一个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:
我该如何修复它?
答案1
我转而使用user_data_file
并将内容放在本地文件中。