-
Notifications
You must be signed in to change notification settings - Fork 10.3k
File provisioning hangs with Terraform 12.* terraforming a Windows server with Powershell 5 installed #22006
Description
Terraform Version
Terraform v0.12.3
+ provider.aws v2.17.0
Terraform Configuration Files
data "aws_ami" "ami" {
most_recent = true
owners = ["self"]
filter {
name = "name"
values = ["TestPowershell5Ami*"]
}
}
resource "aws_instance" "TestTerraform12" {
ami = data.aws_ami.ami.id
count = 1
instance_type = "t2.medium"
availability_zone = "us-east-1a"
key_name = "****"
subnet_id = "subnet-*********"
vpc_security_group_ids = ["sg-*******"]
root_block_device {
volume_size = 80
}
provisioner "file" {
source = "TestFolder1"
destination = "C:/Terraform/TestFolder1"
connection {
host = coalesce(self.public_ip, self.private_ip)
type = "winrm"
user = "Test"
password = "Password"
timeout = "15m"
https = true
port = "5986"
insecure = true
}
}
provisioner "file" {
source = "TestFolder2"
destination = "C:/Terraform/TestFolder2"
connection {
host = coalesce(self.public_ip, self.private_ip)
type = "winrm"
user = "Test"
password = "Password"
timeout = "15m"
https = true
port = "5986"
insecure = true
}
}
}
Debug Output
terraform.exe apply -auto-approve -no-color -target aws_instance.TestTerraform12
data.aws_ami.ami: Refreshing state...
aws_instance.TestTerraform12[0]: Creating...
aws_instance.TestTerraform12[0]: Still creating... [10s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [20s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [30s elapsed]
aws_instance.TestTerraform12[0]: Provisioning with 'file'...
aws_instance.TestTerraform12[0]: Still creating... [40s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [50s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [1m0s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [1m10s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [1m20s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [1m30s elapsed]
...
aws_instance.TestTerraform12[0]: Still creating... [14m40s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [14m50s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [15m0s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [15m10s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [15m20s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [15m30s elapsed]
aws_instance.TestTerraform12[0]: Still creating... [15m40s elapsed]
Interrupt received.
Please wait for Terraform to exit or data loss may occur.
Gracefully shutting down...
Stopping operation...
Two interrupts received. Exiting immediately. Note that data
loss may have occurred.
The interrupt received was me cancelling the cmd line process.
Crash Output
N/A
Expected Behavior
On a Windows Server with Powershell 5 installed, be able to use Terraform 12.* to complete file provisioning of TestFolder1, copying all content and subfolder content, and continue to the next file provisioning step.
This works in Terrafform 11.*
I am using terraform v0.11.8 successfully with provider.aws v1.35.0
Actual Behavior
Since upgrading to Terraform 12.*, the file provisioning of TestFolder1 copies a couple of the 1 KB files over, seems to copy over what can be done in 1 minute, and then stops copying over content. The Terraform console logging continues to report "Still creating..." without end and doesn't obey the timeout. The Terraform process never completes.
Steps to Reproduce
Setup Windows Server 2012 to have Powershell 5
- Create a Window Server 2012 R2 64 bit instance and manually or via cli
For AWS, I am using the source AMI filter
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "Windows_Server-2012-R2_RTM-English-64Bit-Base-*",
"root-device-type": "ebs"
},
"owners": ["amazon"],
"most_recent": true
},- Install Powershell 5 directly via the MSU or through Chocolatey, both have the same effect.
2.1 Chocolatey via, "choco install powershell"
2.2 Manually by downloading Win8.1AndW2K12R2-KB3191564-x64.msu from https://www.microsoft.com/en-us/download/details.aspx?id=54616, Windows Management Framework 5.1 (KB3191564).
2.2.1 Install via the GUI manually or run "Win8.1AndW2K12R2-KB3191564-x64.msu /quiet" in a cmd line Administrator elevated prompt. - Restart the system to complete the install
- Save the image as TestPowershell5Ami
Another option is to leverage a Windows Server 2016 instance, which natively uses Powershell 5.1. For AWS, I used the "name": "Windows_Server-2016-English-Full-Containers-*" source_ami_filter.
Attempt to terraform
- Setup a TestFolder1 folder with over 10 1kb files, something that would take over a minute to file provision on your network.
terraform initterraform apply
Additional Context
Terraform 11.* has never been an issue. The Terraform file isn't new, outside of being upgraded to Terraform 12's syntax, using the automated upgrade cmd. Without Powershll 5 installed, I can terraform the Windows Server system, with Powershell 4.0 natively, just fine. After installing Powershell 5 or against a Windows Server 2016 instance with Powershell 5.1 natively installed, Terraform hangs and never completes or errors out.
The Windows system being terraformed has a Powershell execution policy set to: localmachine bypass.
"set-executionpolicy bypass -force"
The server I run Terraform from has Powershell 5.1 installed.
References
N/A