Skip to content

[FEAT] Disassociate/detach the Public IP address from VM  #5

@mloskot

Description

@mloskot

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 "+1" or "me too" comments, 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

Description

I have created Linux VM using this module with enabled public_ip_sku = Standard.
Then, I decided to delete the public IP, so I set public_ip_sku = null.
The generated plan looked correct indicating the resource "azurerm_public_ip" "public_ip" will be deleted.

Unfortunately, terraform apply failed with the following error:

module.stack_avd.module.vm_test["enabled"].azurerm_public_ip.public_ip[0]:
  Destroying... [id=/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/rg-avd/providers/Microsoft.Network/publicIPAddresses/pip-test]
  Error: deleting Public I P Address (Subscription: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"
  Resource Group Name: "rg-avd"
  Public I P Addresses Name: "pip-test"):
    performing Delete: unexpected status 400 (400 Bad Request) with error:
    PublicIPAddressCannotBeDeleted: Public IP address
      /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/rg-avd/providers/Microsoft.Network/publicIPAddresses/pip-test
      can not be deleted since it is still allocated to resource
      /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/rg-avd/providers/Microsoft.Network/networkInterfaces/nic-test/ipConfigurations/vm-test-nic-ipconfig.
      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.

Would it be possible to improve this module in any way to ensure can be detached?

New or Affected Resource(s)/Data Source(s)

azurerm_network_interface, azurerm_public_ip, azurerm_linux_virtual_machine

Potential Terraform Configuration

No response

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions