Skip to content

Support for networkInterfaceConfigurations in azurerm_(windows|linux)_virtual_machine #25105

Open
@jkroepke

Description

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 "+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 and review the contribution guide to help.

Description

Azure Virtual Machines supports an embedded configuration for network interfaces. This avoids an dedicated handling of NIC inside Terraform. It provides the same experience that we have for data disk.

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

azurerm_(windows|linux)_virtual_machine

Potential Terraform Configuration

resource "azurerm_linux_virtual_machine" {

  # copied from VMSS, seems to be identical..
  network_profile {
    name    = "terraformnetworkprofile"
    primary = true

    ip_configuration {
      name                                   = "TestIPConfiguration"
      primary                                = true
      subnet_id                              = azurerm_subnet.example.id
    }
  }
}

References

Example representation in ARM json:

{
            "copy": {
                "name": "vmLoop",
                "count": "[parameters('numberOfInstances')]"
            },
            "apiVersion": "2023-03-01",
            "type": "Microsoft.Compute/virtualMachines",
            "name": "[concat('vm-', toLower(parameters('os')), '-', parameters('prefix'), '-', copyindex())]",
            "location": "[parameters('location')]",
            "tags": "[parameters('resourceTags')]",
            "properties": {
                "hardwareProfile": {
                    "vmSize": "[parameters('vmSize')]"
                },
                "osProfile": {
                    "computerName": "[concat(toLower(parameters('os')), '-', parameters('prefix'), '-', copyindex())]",
                    "adminUsername": "[parameters('adminUsername')]",
                    "adminPassword": "[parameters('adminPassword')]",
                    "linuxConfiguration": "[variables('linuxConfiguration')[parameters('os')]]"
                },
                "storageProfile": {
                    "imageReference": "[variables('imageReference')[parameters('image')]]",
                    "osDisk": {
                        "createOption": "FromImage",
                        "deleteOption": "Delete"
                    }
                },
                "networkProfile": {
                    "networkApiVersion": "2020-11-01",
                    "networkInterfaceConfigurations": [
                        {
                            "name": "nic1",
                            "properties": {
                                "deleteOption": "Delete",
                                "ipConfigurations": [
                                    {
                                        "name": "ipconfig1",
                                        "properties": {
                                            "subnet": {
                                                "id": "[parameters('subnetId')]"
                                            }
                                        }
                                    }
                                ]
                            }
                        }
                    ]
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true
                    }
                }
            }
        }

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions