Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On compute_instance replacement, Terraform doesn't recognise the network_port will be deleted #48

Closed
rkr-ada opened this issue Feb 14, 2020 · 2 comments

Comments

@rkr-ada
Copy link

rkr-ada commented Feb 14, 2020

When changes to a ecl_compute_instance_v2 resouce are made that forces a replacement of that resource (eg. changing the user_data or adding another network), terraform doesn't recognise that an attached ecl_network_port_v2 resouce will automatically be deleted. So when recreating the compute_instance Terraform tries to attach to the no-longer existing network_port and throws an error.

Terraform Version

Terraform v0.12.20

  • provider.ecl v1.8.1
  • provider.template v2.1.2

Affected Resource(s)

  • ecl_compute_instance_v2
  • ecl_network_port_v2

Terraform Configuration Files

resource "ecl_compute_instance_v2" "vm_instance" {
  name                = "Nodename"
  flavor_id           = "2CPU-16GB"
  key_pair            = "default_keypair"
  user_data           = data.template_cloudinit_config.config.rendered
  stop_before_destroy = true

  network {
    port            = ecl_network_port_v2.vm_instance_node_port.id
    fixed_ip_v4     = var.main_ip
  }

  block_device {
    uuid                  = "<uuid>"
    source_type           = "image"
    volume_size           = 100
    destination_type      = "volume"
    boot_index            = 0
    delete_on_termination = true
  }
}

resource "ecl_network_port_v2" "vm_instance_node_port" {
  name           = "Nodename-port"
  network_id     = var.network_id
  admin_state_up = "true"

  fixed_ip {
    subnet_id = var.network_subnet_id
    ip_address = var.main_ip
  }
}

Expected Behavior

Terraform marks the network_port attached to a vm as deleted when the vm gets deleted/recreated and recreates it before the vm.

Actual Behavior

Terraform deletes and recreates the compute_instance and then tries to connect it to the no-longer existing network_port which obviously fails.

Steps to Reproduce

Create a tf file with a compute instance and a network_port which is referenced in the compute_instances network block. Apply the script. Afterwards, change an argument in the compute_instance resource that forces its recreation (eg. add another network or change the user_data argument). Apply changes.

Regards,
Robert

@kazyshr
Copy link
Contributor

kazyshr commented May 1, 2020

Ports that you created won't be deleted when deleting VM after this maintenance.
https://ecl.ntt.com/en/news/2019110702/

In case where a VM (virtual server) is created using a port (NW interface) created in advance (before the VM), deleting the VM/detaching IF would automatically delete the port on current service design. After this maintenance, the port will no longer be automatically deleted in such cases.

So this issue won't happen now. Can you confirm that again?

Regards,
Kaz

@rkr-ada
Copy link
Author

rkr-ada commented May 8, 2020

Hi,

i tried it and can confirm that the issue has been solved.

Regards,
Robert

@rkr-ada rkr-ada closed this as completed May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants