Azure Compute Dedicated Host Group

This page shows how to write Terraform and Azure Resource Manager for Compute Dedicated Host Group and write them securely.

azurerm_dedicated_host_group (Terraform)

The Dedicated Host Group in Compute can be configured in Terraform with the resource name azurerm_dedicated_host_group. The following sections describe 6 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L1
resource "azurerm_dedicated_host_group" "dedicated_host_group" {
  count                       = length(var.dedicated_host_group)
  name                        = lookup(var.dedicated_host_group[count.index], "name")
  resource_group_name         = element(var.resource_group_name, lookup(var.dedicated_host_group[count.index], "resource_group_id"))
  location                    = element(var.location, lookup(var.dedicated_host_group[count.index], "location_id"))
  platform_fault_domain_count = lookup(var.dedicated_host_group[count.index], "platform_fault_domain_count")
module.tf#L15
resource "azurerm_dedicated_host_group" "dhg" {
  name                        = azurecaf_name.dhg.result
  resource_group_name         = var.resource_group_name
  location                    = var.location
  platform_fault_domain_count = var.settings.platform_fault_domain_count
  automatic_placement_enabled = try(var.settings.automatic_placement_enabled, false)
module.tf#L15
resource "azurerm_dedicated_host_group" "dhg" {
  name                        = azurecaf_name.dhg.result
  resource_group_name         = var.resource_group_name
  location                    = var.location
  platform_fault_domain_count = var.settings.platform_fault_domain_count
  automatic_placement_enabled = try(var.settings.automatic_placement_enabled, false)
main.tf#L1
resource "azurerm_dedicated_host_group" "example" {
  name                        = var.name
  resource_group_name         = module.resource_group.azurerm_resource_group.example.name
  location                    = module.resource_group.azurerm_resource_group.example.location
  platform_fault_domain_count = var.fault_domain_count
main.tf#L7
resource "azurerm_dedicated_host_group" "this" {
  location                    = var.location
  name                        = var.name
  platform_fault_domain_count = var.platform_fault_domain_count
  resource_group_name         = var.resource_group_name
  tags                        = var.tags
main.tf#L7
resource "azurerm_dedicated_host_group" "this" {
  location                    = var.location
  name                        = var.name
  platform_fault_domain_count = var.platform_fault_domain_count
  resource_group_name         = var.resource_group_name
  tags                        = var.tags

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manage a Dedicated Host Group.

Tips: Best Practices for The Other Azure Compute Resources

In addition to the azurerm_linux_virtual_machine, Azure Compute has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_linux_virtual_machine

Ensure to use SSH authentication for virtual machines

It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.

risk-label

azurerm_managed_disk

Ensure to enable the encryption on managed disks

It is better to enable the encryption on managed disks.

risk-label

azurerm_virtual_machine

Ensure to use SSH authentication for virtual machines

It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.

Review your Azure Compute settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Compute/hostGroups (Azure Resource Manager)

The hostGroups in Microsoft.Compute can be configured in Azure Resource Manager with the resource name Microsoft.Compute/hostGroups. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

azuredeploy.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
azuredeploy.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
azuredeploy.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
azuredeploy.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
azuredeploy.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
azuredeploy.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
azuredeploy.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
hostGroups.json#L80
            "type": "Microsoft.Compute/hostGroups"
        },
        {
            "apiVersion": "[variables('apiVersions').hostGroupsHosts]",
            "copy": {
                "count": "[length(parameters('hosts'))]",
azuredeploy.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
azuredeploy.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {

Parameters

  • apiVersion required - string
  • location required - string

    Resource location

  • name required - string

    The name of the dedicated host group.

  • properties required
      • platformFaultDomainCount required - integer

        Number of fault domains that the host group can span.

      • supportAutomaticPlacement optional - boolean

        Specifies whether virtual machines or virtual machine scale sets can be placed automatically on the dedicated host group. Automatic placement means resources are allocated on dedicated hosts, that are chosen by Azure, under the dedicated host group. The value is defaulted to 'false' when not provided. Minimum api-version: 2020-06-01.

  • tags optional - string

    Resource tags

  • type required - string
  • zones optional - array

    Availability Zone to use for this host group. Only single zone is supported. The zone can be assigned only during creation. If not provided, the group supports all zones in the region. If provided, enforces each host in the group to be in the same zone.

Frequently asked questions

What is Azure Compute Dedicated Host Group?

Azure Compute Dedicated Host Group is a resource for Compute of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Compute Dedicated Host Group?

For Terraform, the mikamakusa/terraform, aztfmod/terraform-azurerm-caf and pkhuntia/aztfmod source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the mgyannainglin/az, senareddt2019/Sample-Scripts and zzhang01/azure-quickstart-templates source code examples are useful. See the Azure Resource Manager Example section for further details.