Azure Compute Placement Group
This page shows how to write Terraform and Azure Resource Manager for Compute Placement Group and write them securely.
azurerm_proximity_placement_group (Terraform)
The Placement Group in Compute can be configured in Terraform with the resource name azurerm_proximity_placement_group
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_proximity_placement_group" "ppg" {
name = azurecaf_name.ppg.result
location = var.location
resource_group_name = var.resource_group_name
tags = local.tags
resource "azurerm_proximity_placement_group" "ppg" {
name = azurecaf_name.ppg.result
location = var.location
resource_group_name = var.resource_group_name
tags = local.tags
resource "azurerm_proximity_placement_group" "ppg" {
name = azurecaf_name.ppg.result
location = var.location
resource_group_name = var.resource_group_name
tags = local.tags
resource "azurerm_proximity_placement_group" "ppg" {
name = azurecaf_name.ppg.result
location = var.location
resource_group_name = var.resource_group_name
tags = local.tags
resource "azurerm_proximity_placement_group" "group" {
name = var.name
location = var.location != null ? var.location : data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
tags = var.tags
}
resource "azurerm_proximity_placement_group" "example" {
name = var.name
location = module.resource_group.azurerm_resource_group.example.location
resource_group_name = module.resource_group.azurerm_resource_group.example.name
resource "azurerm_proximity_placement_group" "this" {
location = var.location
name = var.name
resource_group_name = var.resource_group_name
tags = var.tags
resource "azurerm_proximity_placement_group" "main" {
for_each = var.proximity_placement_group
name = each.value.name
resource_group_name = azurerm_resource_group.main[each.value.resource_group_key].name
location = azurerm_resource_group.main[each.value.resource_group_key].location
}
resource "azurerm_proximity_placement_group" "primary" {
name = "example-placement-group"
location = module.resource_group.location
resource_group_name = module.resource_group.name
tags = module.metadata.tags
}
resource "azurerm_proximity_placement_group" "this" {
location = var.location
name = var.name
resource_group_name = var.resource_group_name
tags = var.tags
Parameters
-
id
optional computed - string -
location
required - string -
name
required - string -
resource_group_name
required - string -
tags
optional - map from string to string -
timeouts
single block
Explanation in Terraform Registry
Manages a proximity placement group for virtual machines, virtual machine scale sets and availability sets.
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/proximityPlacementGroups (Azure Resource Manager)
The proximityPlacementGroups in Microsoft.Compute can be configured in Azure Resource Manager with the resource name Microsoft.Compute/proximityPlacementGroups
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Compute/proximityPlacementGroups",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
}
},
"201": {
"body": {
"type": "Microsoft.Compute/proximityPlacementGroups",
"apiVersion": "2020-12-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
"properties": {
"type": "Microsoft.Compute/proximityPlacementGroups",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
}
},
"201": {
"body": {
"type": "Microsoft.Compute/proximityPlacementGroups",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
}
},
"201": {
"body": {
"type": "Microsoft.Compute/proximityPlacementGroups",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
}
},
"201": {
"body": {
"type": "Microsoft.Compute/proximityPlacementGroups",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
}
},
"201": {
"body": {
"type": "Microsoft.Compute/proximityPlacementGroups",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
}
},
"201": {
"body": {
"type": "Microsoft.Compute/proximityPlacementGroups",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
}
},
"201": {
"body": {
"type": "Microsoft.Compute/proximityPlacementGroups",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
}
},
"201": {
"body": {
"type": "Microsoft.Compute/proximityPlacementGroups",
"name": "[parameters('ppgName')]",
"location": "[parameters('location')]",
"tags": "[ if(contains(parameters('tagsByResource'), 'Microsoft.Compute/proximityPlacementGroups'), parameters('tagsByResource')['Microsoft.Compute/proximityPlacementGroups'], json('{}')) ]"
}
],
Parameters
apiVersion
required - stringlocation
required - stringResource location
name
required - stringThe name of the proximity placement group.
properties
requiredcolocationStatus
optionalcode
optional - stringThe status code.
displayStatus
optional - stringThe short localizable label for the status.
level
optional - stringThe level code.
message
optional - stringThe detailed status message, including for alerts and error messages.
time
optional - stringThe time of the status.
proximityPlacementGroupType
optional - stringSpecifies the type of the proximity placement group. Possible values are: Standard : Co-locate resources within an Azure region or Availability Zone. Ultra : For future use.
tags
optional - stringResource tags
type
required - string
Frequently asked questions
What is Azure Compute Placement Group?
Azure Compute Placement 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 Placement Group?
For Terraform, the anmoltoppo/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 Azure/autorest.az, sebastianhubersw1/ARMTemplates and Azure/azure-sdk-tools source code examples are useful. See the Azure Resource Manager Example section for further details.