Hi @JustLeo and @jeremywiles,
Using provisioners tends to add all sorts of extra complexity to Terraform usage, due to the need to properly configure credentials, ensure that there is connectivity on the appropriate TCP port between Terraform and the remote host, etc. For that reason, provisioners are a last resort.
While it should be possible to get WinRM working, it’s generally very hard to help with provisioner-related issues in a forum setting due to how many different settings must be configured just right in order to make them work and how dependent the behavior is on your surrounding environment. I’d suggest looking for other ways to solve your problem instead.
For the situation of running Windows Server images provided by Amazon on EC2, I’d suggest investigating the use of the EC2Config service with the
user_data setting on
That avoids the need for Terraform to connect to your EC2 instance at all, because the necessary configuration and/or scripts are provided through the EC2 API instead. This will often also result in faster boot-up times because the
user_data processing can happen as soon as the EC2Config service starts up, rather than waiting until Terraform is able to access the instance with WinRM or SSH.
Other cloud compute vendors have similar mechanisms for specifying launch configuration and scripts via the platform API, described in each vendor’s own documentation. The Terraform provisioners documentation lists some examples for common platforms as a starting point.