Azure Compute Dedicated Host

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

azurerm_dedicated_host (Terraform)

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

Example Usage from GitHub

main.tf#L1
resource "azurerm_dedicated_host" "dedicated_host" {
  count                   = length(var.dedicated_hosts)
  name                    = lookup(var.dedicated_hosts[count.index], "name")
  location                = element(var.location, lookup(var.dedicated_hosts[count.index], "location_id"))
  dedicated_host_group_id = element(var.dedicated_host_group_id, lookup(var.dedicated_hosts[count.index], "dedicated_host_group_id"))
  sku_name                = lookup(var.dedicated_hosts[count.index], "sku_name")
module.tf#L14
resource "azurerm_dedicated_host" "dh" {
  name                    = azurecaf_name.dh.result
  dedicated_host_group_id = var.dedicated_host_group_id
  location                = var.location
  sku_name                = var.settings.sku_name
  platform_fault_domain   = var.settings.platform_fault_domain
main.tf#L1
resource "azurerm_dedicated_host" "example" {
  name                    = var.name
  location                = module.resource_group.azurerm_resource_group.example.location
  dedicated_host_group_id = module.dedicated_host_group.azurerm_dedicated_host_group.example.id
  sku_name                = var.sku
  platform_fault_domain   = var.platform_fault_domain
module.tf#L14
resource "azurerm_dedicated_host" "dh" {
  name                    = azurecaf_name.dh.result
  dedicated_host_group_id = var.dedicated_host_group_id
  location                = var.location
  sku_name                = var.settings.sku_name
  platform_fault_domain   = var.settings.platform_fault_domain
main.tf#L7
resource "azurerm_dedicated_host" "this" {
  auto_replace_on_failure = var.auto_replace_on_failure
  dedicated_host_group_id = var.dedicated_host_group_id
  license_type            = var.license_type
  location                = var.location
  name                    = var.name
main.tf#L7
resource "azurerm_dedicated_host" "this" {
  auto_replace_on_failure = var.auto_replace_on_failure
  dedicated_host_group_id = var.dedicated_host_group_id
  license_type            = var.license_type
  location                = var.location
  name                    = var.name
module.tf#L14
resource "azurerm_dedicated_host" "dh" {
  name                    = azurecaf_name.dh.result
  dedicated_host_group_id = var.dedicated_host_group_id
  location                = var.location
  sku_name                = var.settings.sku_name
  platform_fault_domain   = var.settings.platform_fault_domain

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 within 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/hosts (Azure Resource Manager)

The hostGroups/hosts in Microsoft.Compute can be configured in Azure Resource Manager with the resource name Microsoft.Compute/hostGroups/hosts. 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": {
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": {

Parameters

  • apiVersion required - string
  • location required - string

    Resource location

  • name required - string

    The name of the dedicated host .

  • properties required
      • autoReplaceOnFailure optional - boolean

        Specifies whether the dedicated host should be replaced automatically in case of a failure. The value is defaulted to 'true' when not provided.

      • licenseType optional - string

        Specifies the software license type that will be applied to the VMs deployed on the dedicated host. Possible values are: None Windows_Server_Hybrid Windows_Server_Perpetual Default: None.

      • platformFaultDomain optional - integer

        Fault domain of the dedicated host within a dedicated host group.

  • sku required
      • capacity optional - integer

        Specifies the number of virtual machines in the scale set.

      • name optional - string

        The sku name.

      • tier optional - string

        Specifies the tier of virtual machines in a scale set. Possible Values: Standard Basic

  • tags optional - string

    Resource tags

  • type required - string

Frequently asked questions

What is Azure Compute Dedicated Host?

Azure Compute Dedicated Host 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?

For Terraform, the mikamakusa/terraform, aztfmod/terraform-azurerm-caf and VentsislavDinev/en_sample 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.