Skip to content

Unable to remove public IP from existing instance #286

@ppawlowski

Description

@ppawlowski

Is there an existing issue for this?

  • I have searched the existing issues

Greenfield/Brownfield provisioning

brownfield

Terraform Version

1.3.10

Module Version

5.2.0

AzureRM Provider Version

v3.83.0

Affected Resource(s)/Data Source(s)

azurerm_network_interface

Terraform Configuration Files

data "azurerm_resource_group" "myrg" {
  name = "my-rg"
}

module "myvnet" {
  source  = "Azure/vnet/azurerm"
  version = "2.5.0"

  vnet_name           = "my-vnet"
  resource_group_name = data.azurerm_resource_group.myrg.name
  address_space       = [
    "172.23.0.0/28",
    "192.168.104.104/29",
    "192.168.105.8/29"]
  subnet_prefixes     = [
    "172.23.0.0/28",
    "192.168.104.104/29",
    "192.168.105.8/29"]
  subnet_names        = [
    "GatewaySubnet",
    "subnet1",
    "subnet2"]

  depends_on = [data.azurerm_resource_group.myrg]
}

module "myvm" {
  source  = "Azure/compute/azurerm"
  version = "5.2.0"

  resource_group_name           = data.azurerm_resource_group.myrg.name
  location                      = data.azurerm_resource_group.myrg.location
  vnet_subnet_id                = module.myvnet.vnet_subnets[1]
  nb_instances                  = 1
  nb_public_ip                  = 0
  vm_os_simple                  = "UbuntuServer"
  vm_hostname                   = "myVmHostname"
  admin_username                = "adminusername"
  enable_ssh_key                = true
  ssh_key                       = ""
  ssh_key_values                = [###EDITED###]
  remote_port                   = "22"
  storage_account_type          = "Standard_LRS"
  vm_size                       = "Standard_B1ms"
  delete_os_disk_on_termination = true
  identity_type                 = "SystemAssigned"

  depends_on = [
    data.azurerm_resource_group.myrg,
    module.myvnet
  ]
}

tfvars variables values

not used

Debug Output/Panic Output

│ Error: parsing "" as an PublicIpAddress ID: parsing Azure ID: parse "": empty url
│
│   with module.myvm.azurerm_network_interface.vm[0],
│   on .terraform/modules/myvm/main.tf line 446, in resource "azurerm_network_interface" "vm":
│  446:     public_ip_address_id = length(azurerm_public_ip.vm[*].id) > 0 ? element(concat(azurerm_public_ip.vm[*].id, tolist([
│  447:       ""
│  448:     ])), count.index) : ""

Expected Behaviour

Public IP address should be removed from existing VM

Actual Behaviour

Terraform fails with above described error. There is no possibility to have a VM instance without public IP address.

Steps to Reproduce

  1. terraform plan
  2. terraform apply

Important Factoids

No response

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions