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

cannot destroy azurerm_network_interface_backend_address_pool_association when the network interface was manually deleted #2491

Closed
rgl opened this issue Dec 11, 2018 · 7 comments · Fixed by #8267

Comments

@rgl
Copy link
Contributor

rgl commented Dec 11, 2018

I was trying to launch two virtual machines behind a load balancer. But after 45 minutes, azure failed to create one of the machines, to try to recover the situation, I've manually deleted the virtual machine and tried to run terraform apply again, but it kept on failing due to missing resources, until I've end-up with:

Error: Error refreshing state: 1 error(s) occurred:

* azurerm_network_interface_backend_address_pool_association.web: 2 error(s) occurred:

* azurerm_network_interface_backend_address_pool_association.web[1]: azurerm_network_interface_backend_address_pool_association.web.1: Network Interface "web2" (Resource Group "rgl-load-balancer-example") was not found!
* azurerm_network_interface_backend_address_pool_association.web[0]: azurerm_network_interface_backend_address_pool_association.web.0: Network Interface "web1" (Resource Group "rgl-load-balancer-example") was not found!

Which I could not recover from. This made me think that terraform should not refuse to run when a resource was manually delete from azure portal. It should ignore that fact and assume the resource was MIA and re-create it again.

Terraform (and AzureRM Provider) Version

Terraform v0.11.9

  • provider.azurerm v1.19.0
  • provider.random v2.0.0

Affected Resource(s)

  • azurerm_network_interface_backend_address_pool_association

Configuration

resource "azurerm_lb_backend_address_pool" "web" {
  resource_group_name = "${azurerm_resource_group.example.name}"
  loadbalancer_id     = "${azurerm_lb.web.id}"
  name                = "web"
}

resource "azurerm_network_interface_backend_address_pool_association" "web" {
  count                   = "${var.web_vm_count}"
  network_interface_id    = "${azurerm_network_interface.web.*.id[count.index]}"
  ip_configuration_name   = "web"
  backend_address_pool_id = "${azurerm_lb_backend_address_pool.web.id}"
}

Expected Behavior

It should ignore manually deleted / non-long existing resources.

Actual Behavior

It refuses to do anything.

Steps to Reproduce

  1. terraform apply
  2. manually delete a network interface that is also inside the load balancer backend
  3. try terraform apply or destroy
@cehoffman
Copy link

cehoffman commented Dec 13, 2018

Additional information for this since we have experience this issue as well. This worked in the 1.19 release and was broken in 1.20. We have logs verifying such.

Correction, this correctly worked with removed associations but fails when the nic has been deleted.

@jawiz
Copy link

jawiz commented Jun 6, 2019

How did you recover from this state?

@OffColour
Copy link

Having the same issue.
After removing various items from the state, I finally got it to run after running:
terrafrom state rm azurerm_network_interface_backend_address_pool_association.nameoftheassociation
for the association that had the NIC in it.

Don't know if it would have worked if that had been the first thing I deleted or it was cumulative.

@ArcturusZhang
Copy link
Contributor

This issue is a subset of issue #4330

@danielgriggs
Copy link

This is still an unsolved problem.
If a VM NIC that is in a load balancer is removed from outside TF, on a plan, apply, or refresh TF just bails. I would expect it to recreate the resource. Not pack a sad.

@ghost
Copy link

ghost commented Sep 4, 2020

This has been released in version 2.26.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.26.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Sep 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Sep 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
8 participants