Hello all,
we are using Terraform v0.12.29 to manage a group of VMs on Azure using azurerm 2.10.0.
Whenever we run “apply”, Terraform wants to recreate the VMs:
It seems to me, that this is related to the public and private IPs, since these are marked with “-”.
The configuration of the public IP and network interface looks like this:
resource "azurerm_public_ip" "pip" {
count = var.public_ip ? 1 : 0
name = "${local.name_prefix}-pip"
location = var.location
resource_group_name = var.resource_group_name
#allocation_method = "Dynamic"
allocation_method = var.public_ip_dynamic ? "Dynamic" : "Static"
sku = "Basic"
tags = var.common_tags
}
resource "azurerm_network_interface" "nic" {
name = "${local.name_prefix}-nic"
location = var.location
resource_group_name = var.resource_group_name
count = var.nic == [1] ? 1:0
ip_configuration {
name = "nic-config"
subnet_id = var.subnet_id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = var.public_ip ? azurerm_public_ip.pip[0].id : null
}
tags = var.common_tags
}
resource "azurerm_linux_virtual_machine" "vm" {
name = "${local.name_prefix}-vm"
location = var.location
resource_group_name = var.resource_group_name
network_interface_ids = var.nic == [1] ? [azurerm_network_interface.nic[0].id] : var.nic
size = var.vm_size
admin_username = var.admin_username
computer_name = "${local.name_prefix}-host"
custom_data = var.custom_data
}
Anyone have an idea what we may be doing wrong?
Best regards and thanks in advance!
1 post - 1 participant