I am using count in the resource azurerm_network_interface to create multiple secondary iip addresses, however it only configures one primary address, manually If enter multiple ip_configuration commands it works fine
Here is the configuration
resource "azurerm_network_interface" "appnic" {
count = var.app_count
name = "app_nic"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
ip_configuration {
name = "app_ip_${count.index}"
subnet_id = azurerm_subnet.external-subnet.id
private_ip_address_allocation = "Dynamic"
}
}
Here is the terraform output
random_id.id: Creating...
random_id.id: Creation complete after 0s [id=IBY]
azurerm_resource_group.rg: Creating...
azurerm_resource_group.rg: Creation complete after 6s [id=/subscriptions/187fa2f3-5d57-4e6a-9b1b-f92ba7adbf42/resourceGroups/student-2016-rg]
azurerm_virtual_network.azv: Creating...
azurerm_virtual_network.azv: Still creating... [10s elapsed]
azurerm_virtual_network.azv: Creation complete after 12s [id=/subscriptions/187fa2f3-5d57-4e6a-9b1b-f92ba7adbf42/resourceGroups/student-2016-rg/providers/Microsoft.Network/virtualNetworks/external-virtual-network]
azurerm_subnet.external-subnet: Creating...
azurerm_subnet.external-subnet: Still creating... [10s elapsed]
azurerm_subnet.external-subnet: Creation complete after 11s [id=/subscriptions/187fa2f3-5d57-4e6a-9b1b-f92ba7adbf42/resourceGroups/student-2016-rg/providers/Microsoft.Network/virtualNetworks/external-virtual-network/subnets/external-subnet]
azurerm_network_interface.appnic[2]: Creating...
azurerm_network_interface.appnic[3]: Creating...
azurerm_network_interface.appnic[1]: Creating...
azurerm_network_interface.appnic[0]: Creating...
azurerm_network_interface.appnic[3]: Creation complete after 9s [id=/subscriptions/187fa2f3-5d57-4e6a-9b1b-f92ba7adbf42/resourceGroups/student-2016-rg/providers/Microsoft.Network/networkInterfaces/app_nic]
azurerm_network_interface.appnic[2]: Still creating... [10s elapsed]
azurerm_network_interface.appnic[1]: Still creating... [10s elapsed]
azurerm_network_interface.appnic[0]: Still creating... [10s elapsed]
azurerm_network_interface.appnic[2]: Creation complete after 11s [id=/subscriptions/187fa2f3-5d57-4e6a-9b1b-f92ba7adbf42/resourceGroups/student-2016-rg/providers/Microsoft.Network/networkInterfaces/app_nic]
azurerm_network_interface.appnic[1]: Creation complete after 12s [id=/subscriptions/187fa2f3-5d57-4e6a-9b1b-f92ba7adbf42/resourceGroups/student-2016-rg/providers/Microsoft.Network/networkInterfaces/app_nic]
azurerm_network_interface.appnic[0]: Creation complete after 14s [id=/subscriptions/187fa2f3-5d57-4e6a-9b1b-f92ba7adbf42/resourceGroups/student-2016-rg/providers/Microsoft.Network/networkInterfaces/app_nic]
Apply complete! Resources: 8 added, 0 changed, 0 destroyed.
Outputs:
IP_assigned = [
{
"applied_dns_servers" = tolist([])
"dns_servers" = tolist([])
"edge_zone" = ""
"enable_accelerated_networking" = false
"enable_ip_forwarding" = false
"id" = "/subscriptions/XXXXXXX/resourceGroups/student-2016-rg/providers/Microsoft.Network/networkInterfaces/app_nic"
"internal_dns_name_label" = ""
"internal_domain_name_suffix" = "kqw5pv0hfk1unfgwkvhmsxv5wf.bx.internal.cloudapp.net"
"ip_configuration" = tolist([
{
"gateway_load_balancer_frontend_ip_configuration_id" = ""
"name" = "app_ip_0"
"primary" = true
"private_ip_address" = "10.0.2.5"
"private_ip_address_allocation" = "Dynamic"
"private_ip_address_version" = "IPv4"
"public_ip_address_id" = ""
"subnet_id" = "/subscriptions/2/resourceGroups/student-2016-rg/providers/Microsoft.Network/virtualNetworks/external-virtual-network/subnets/external-subnet"
},
])
"location" = "eastus"
"mac_address" = ""
"name" = "app_nic"
"private_ip_address" = "10.0.2.5"
"private_ip_addresses" = tolist([
"10.0.2.5",
])
"resource_group_name" = "student-2016-rg"
"tags" = tomap(null) /* of string */
"timeouts" = null /* object */
"virtual_machine_id" = ""
},
{
"applied_dns_servers" = tolist([])
"dns_servers" = tolist([])
"edge_zone" = ""
"enable_accelerated_networking" = false
"enable_ip_forwarding" = false
"id" = "/subscriptions/xXXXXXXXXX2/resourceGroups/student-2016-rg/providers/Microsoft.Network/networkInterfaces/app_nic"
"internal_dns_name_label" = ""
"internal_domain_name_suffix" = "kqw5pv0hfk1unfgwkvhmsxv5wf.bx.internal.cloudapp.net"
"ip_configuration" = tolist([
{
"gateway_load_balancer_frontend_ip_configuration_id" = ""
"name" = "app_ip_1"
"primary" = true
"private_ip_address" = "10.0.2.4"
"private_ip_address_allocation" = "Dynamic"
"private_ip_address_version" = "IPv4"
"public_ip_address_id" = ""
"subnet_id" = "/subscriptions/12/resourceGroups/student-2016-rg/providers/Microsoft.Network/virtualNetworks/external-virtual-network/subnets/external-subnet"
},
])
"location" = "eastus"
"mac_address" = ""
"name" = "app_nic"
"private_ip_address" = "10.0.2.4"
"private_ip_addresses" = tolist([
"10.0.2.4",
])
"resource_group_name" = "student-2016-rg"
"tags" = tomap(null) /* of string */
"timeouts" = null /* object */
"virtual_machine_id" = ""
},
{
"applied_dns_servers" = tolist([])
"dns_servers" = tolist([])
"edge_zone" = ""
"enable_accelerated_networking" = false
"enable_ip_forwarding" = false
"id" = "/subscriptions//resourceGroups/student-2016-rg/providers/Microsoft.Network/networkInterfaces/app_nic"
"internal_dns_name_label" = ""
"internal_domain_name_suffix" = "kqw5pv0hfk1unfgwkvhmsxv5wf.bx.internal.cloudapp.net"
"ip_configuration" = tolist([
{
"gateway_load_balancer_frontend_ip_configuration_id" = ""
"name" = "app_ip_2"
"primary" = true
"private_ip_address" = "10.0.2.5"
"private_ip_address_allocation" = "Dynamic"
"private_ip_address_version" = "IPv4"
"public_ip_address_id" = ""
"subnet_id" = "/subscriptions/42/resourceGroups/student-2016-rg/providers/Microsoft.Network/virtualNetworks/external-virtual-network/subnets/external-subnet"
},
])
"location" = "eastus"
"mac_address" = ""
"name" = "app_nic"
"private_ip_address" = "10.0.2.5"
"private_ip_addresses" = tolist([
"10.0.2.5",
])
"resource_group_name" = "student-2016-rg"
"tags" = tomap(null) /* of string */
"timeouts" = null /* object */
"virtual_machine_id" = ""
},
{
"applied_dns_servers" = tolist([])
"dns_servers" = tolist([])
"edge_zone" = ""
"enable_accelerated_networking" = false
"enable_ip_forwarding" = false
"id" = "/subscriptions//resourceGroups/student-2016-rg/providers/Microsoft.Network/networkInterfaces/app_nic"
"internal_dns_name_label" = ""
"internal_domain_name_suffix" = "kqw5pv0hfk1unfgwkvhmsxv5wf.bx.internal.cloudapp.net"
"ip_configuration" = tolist([
{
"gateway_load_balancer_frontend_ip_configuration_id" = ""
"name" = "app_ip_3"
"primary" = true
"private_ip_address" = "10.0.2.4"
"private_ip_address_allocation" = "Dynamic"
"private_ip_address_version" = "IPv4"
"public_ip_address_id" = ""
"subnet_id" = "/subscriptions//resourceGroups/student-2016-rg/providers/Microsoft.Network/virtualNetworks/external-virtual-network/subnets/external-subnet"
},
])
"location" = "eastus"
"mac_address" = ""
"name" = "app_nic"
"private_ip_address" = "10.0.2.4"
"private_ip_addresses" = tolist([
"10.0.2.4",
])
"resource_group_name" = "student-2016-rg"
"tags" = tomap(null) /* of string */
"timeouts" = null /* object */
"virtual_machine_id" = ""
},
]
ResourceGroup = "student-2016-rg"