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
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")
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)
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)
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
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
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
Parameters
-
id
optional computed - string -
location
required - string -
name
required - string -
platform_fault_domain_count
required - number -
resource_group_name
required - string -
tags
optional - map from string to string -
zones
optional - list of string -
timeouts
single block
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.
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.
azurerm_managed_disk
Ensure to enable the encryption on managed disks
It is better to enable the encryption on managed disks.
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.
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
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "Microsoft.Compute/hostGroups"
},
{
"apiVersion": "[variables('apiVersions').hostGroupsHosts]",
"copy": {
"count": "[length(parameters('hosts'))]",
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
Parameters
apiVersion
required - stringlocation
required - stringResource location
name
required - stringThe name of the dedicated host group.
properties
requiredplatformFaultDomainCount
required - integerNumber of fault domains that the host group can span.
supportAutomaticPlacement
optional - booleanSpecifies 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 - stringResource tags
type
required - stringzones
optional - arrayAvailability 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.