title: Can I create an AMI with packer on macOS?
body: <p>I am trying to build a Windows AMI (Custom AWS Image) with Packer.
  Is there a way to use WinRM on macOS, or do I have to build the image on a windows machine?</p>
  
  <p>We are using a mix of Ubuntu and Windows servers and the majority are Ubuntu servers. I would like to build it all on my macbook. In production we are using Jenkins.</p>
  
  <p>The purpose of the image is to run IIS and Sitecore.</p>
  
  <p>I need to install</p>
  
  <ul>
  <li>IIS</li>
  <li>Sitecore</li>
  <li>Filebeat</li>
  </ul>
  
  <p>Code example:</p>
  
  <pre><code>resource "aws_key_pair" "mykey" {
    key_name = "mykey"
    public_key = "${file("${var.PATH_TO_PUBLIC_KEY}")}"
  }
  
  resource "aws_instance" "win-example" {
    security_groups = [ "${aws_security_group.windows-admin.id}" ]
    subnet_id = "subnet-730c9c16"
    ami = "ami-40003a26"
    instance_type = "t2.micro"
    associate_public_ip_address = true
    key_name = "${aws_key_pair.mykey.key_name}"
    tags {
      Name = "win-example"
    }
    user_data = &lt;&lt;EOF
  &lt;powershell&gt;
  net user ${var.INSTANCE_USERNAME} ${var.INSTANCE_PASSWORD} /add
  net localgroup administrators ${var.INSTANCE_USERNAME} /add
  
  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
  &lt;/powershell&gt;
  EOF
  
    provisioner "file" {
      source = "test.txt"
      destination = "C:/test.txt"
      connection {
        type = "winrm"
        user = "${var.INSTANCE_USERNAME}"
        password = "${var.INSTANCE_PASSWORD}"
        insecure = true
        timeout = "10m"
      }
    }
    connection {
      type = "winrm"
      user = "${var.INSTANCE_USERNAME}"
      password = "${var.INSTANCE_PASSWORD}"
      insecure = true
      timeout = "10m"
    }
  }
  </code></pre>
  
  <p>terraform reports an error:</p>
  
  <pre><code>Error applying plan:
  1 error(s) occurred:
  * aws_instance.win-example: 1 error(s) occurred:
  * unknown error Post http://54.229.229.22:5985/wsman: dial tcp 54.229.229.22:5985: getsockopt: operation timed out
  </code></pre>
  
  <p>The powershell script runs and the user is created but the file "test.txt" are not copied to the server.</p>