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

proximity_placement_group.tf#L14
resource "azurerm_proximity_placement_group" "ppg" {

  name                = azurecaf_name.ppg.result
  location            = var.location
  resource_group_name = var.resource_group_name
  tags                = local.tags
proximity_placement_group.tf#L14
resource "azurerm_proximity_placement_group" "ppg" {

  name                = azurecaf_name.ppg.result
  location            = var.location
  resource_group_name = var.resource_group_name
  tags                = local.tags
proximity_placement_group.tf#L14
resource "azurerm_proximity_placement_group" "ppg" {

  name                = azurecaf_name.ppg.result
  location            = var.location
  resource_group_name = var.resource_group_name
  tags                = local.tags
proximity_placement_group.tf#L14
resource "azurerm_proximity_placement_group" "ppg" {

  name                = azurecaf_name.ppg.result
  location            = var.location
  resource_group_name = var.resource_group_name
  tags                = local.tags
main.tf#L5
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
}
main.tf#L1
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
main.tf#L7
resource "azurerm_proximity_placement_group" "this" {
  location            = var.location
  name                = var.name
  resource_group_name = var.resource_group_name
  tags                = var.tags

availability.tf#L19
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
}
main.tf#L86
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
}
main.tf#L7
resource "azurerm_proximity_placement_group" "this" {
  location            = var.location
  name                = var.name
  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

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.

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/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

CreateOrUpdateAProximityPlacementGroup.json#L22
        "type": "Microsoft.Compute/proximityPlacementGroups",
        "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
      }
    },
    "201": {
      "body": {
proximityPlacementGroup.json#L29
            "type": "Microsoft.Compute/proximityPlacementGroups",
            "apiVersion": "2020-12-01",
            "name": "[parameters('name')]",
            "location": "[parameters('location')]",
            "tags": "[parameters('tags')]",
            "properties": {
CreateOrUpdateAProximityPlacementGroup.json#L22
        "type": "Microsoft.Compute/proximityPlacementGroups",
        "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
      }
    },
    "201": {
      "body": {
CreateOrUpdateAProximityPlacementGroup.json#L22
        "type": "Microsoft.Compute/proximityPlacementGroups",
        "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
      }
    },
    "201": {
      "body": {
CreateOrUpdateAProximityPlacementGroup.json#L22
        "type": "Microsoft.Compute/proximityPlacementGroups",
        "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
      }
    },
    "201": {
      "body": {
CreateOrUpdateAProximityPlacementGroup.json#L22
        "type": "Microsoft.Compute/proximityPlacementGroups",
        "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
      }
    },
    "201": {
      "body": {
CreateOrUpdateAProximityPlacementGroup.json#L22
        "type": "Microsoft.Compute/proximityPlacementGroups",
        "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
      }
    },
    "201": {
      "body": {
CreateOrUpdateAProximityPlacementGroup.json#L22
        "type": "Microsoft.Compute/proximityPlacementGroups",
        "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
      }
    },
    "201": {
      "body": {
CreateOrUpdateAProximityPlacementGroup.json#L22
        "type": "Microsoft.Compute/proximityPlacementGroups",
        "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup"
      }
    },
    "201": {
      "body": {
template.json#L23
            "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 - string
  • location required - string

    Resource location

  • name required - string

    The name of the proximity placement group.

  • properties required
      • colocationStatus optional
          • code optional - string

            The status code.

          • displayStatus optional - string

            The short localizable label for the status.

          • level optional - string

            The level code.

          • message optional - string

            The detailed status message, including for alerts and error messages.

          • time optional - string

            The time of the status.

      • proximityPlacementGroupType optional - string

        Specifies 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 - string

    Resource 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.