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

Public IP Deletion Fails because it's not disassociated from NIC first #27539

Open
1 task done
petewilcock opened this issue Sep 30, 2024 · 0 comments
Open
1 task done

Comments

@petewilcock
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.8.1

AzureRM Provider Version

4.3.0

Affected Resource(s)/Data Source(s)

azurerm_public_ip

Terraform Configuration Files

resource "azurerm_public_ip" "public_ip" {
  count               = var.assign_public_ip ? 1 : 0
  name                = "${var.server_name}-pip"
  location            = var.azure_location
  resource_group_name = var.resource_group_name
  sku                 = "Basic"
  allocation_method   = var.public_ip_allocation_method
}

resource "azurerm_network_interface" "server_nic" {
  name                = var.server_name
  location            = var.azure_location
  resource_group_name = var.resource_group_name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = var.subnet_id
    private_ip_address_allocation = var.private_ip_allocation_method
    private_ip_address            = var.private_ip_allocation_method == "Static" ? var.private_ip_address : null
    public_ip_address_id          = var.assign_public_ip ? azurerm_public_ip.public_ip[0].id : null
  }

}

Debug Output/Panic Output

Public I P Addresses Name: "server-pip"): performing Delete: unexpected status 400 (400 Bad Request) with error: PublicIPAddressCannotBeDeleted: Public IP address /subscriptions/-/resourceGroups/-/providers/Microsoft.Network/publicIPAddresses/server-pip can not be deleted since it is still allocated to resource /subscriptions/-/resourceGroups/-/providers/Microsoft.Network/networkInterfaces/-/ipConfigurations/internal. In order to delete the public IP, disassociate/detach the Public IP address from the resource.  To learn how to do this, see aka.ms/deletepublicip

Expected Behaviour

Provider should understand dependency ordering and disassociate the IP address to be deleted first in the azurerm_network_interface before proceeding to delete azurerm_public_ip

Actual Behaviour

Terraform always tries to delete IP first, leading to above error before disassociation can occur.

Steps to Reproduce

terraform apply

Important Factoids

No response

References

Alleges to have been fixed in a previous issue, but this was either incorrect, or there has been a regression in the meantime.

#2566

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant