Open dcosson opened 8 years ago
I am seeing same behavior when using Openstack as provider. running terraform version: 0.7.2
to reproduce: Prepare your instance.tf file for Openstack provider, you can use this below and feel free to change image to anything you want same for some others parameters:
resource "openstack_compute_instance_v2" "1_Windows2012R2" { count = "1" name = "Windows 2012 R2" image_name = "win-2012-r2" flavor_name = "m1.large" network { name = "public" } floating_ip = "${openstack_compute_floatingip_v2.1_Windows2012R2_ip.address}" key_pair = "dev" security_groups = ["default"]
connection { user = "Admin" host = "${openstack_compute_floatingip_v2.1_Windows2012R2_ip.address}" private_key = "/home/ecerquei/.ssh/id_rsa" timeout = "10m" }
provisioner "remote-exec" { inline = [ "dir" ] } } resource "openstack_compute_floatingip_v2" "1_Windows2012R2_ip" { region = "" pool = "10.10.127.0/22" }
Provision the system resource(s): $terraform apply
then wait 5 seconds (just to get time enough to start provisioning) then click CTRL+C
you will see the rest of log as below with the message as mentioned at title of this issue
network.0.port: "" => "
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
I hope it helps!
Experiencing this with Azure VMs as well, it slows down our workflow since the timeouts are lengthy and having to manually destroy the resources on Azure is tedious.
Terraform Version
0.6.15
Affected Resource(s)
Terraform Configuration Files
Any remote-exec script
When creating an instance with a remote-exec script, sometimes the script hangs and it's obvious that it's not going to work. For example, maybe I forgot -y on an apt-get install. When you hit 'ctrl-c' in terraform, it prints
Interrupt received. Gracefully shutting down...
but then it will never exit. So, I either have to kill the process by hitting ctrl-c again which means it never syncs to the tfstate file so I have to delete the orphaned ec2 instance(s) manually, or I have to just wait until the timeout.I think it would be better if terraform would kill the remote-exec script immediately on ctrl-c, and then it could gracefully clean up by adding the tainted ec2 instances to the tfstate file and exit.