Skip to content

azurermDiskPoolManagedDiskAttachment

Manages a Disk Pool Managed Disk Attachment.

!> Note: Azure are officially halting the preview of Azure Disk Pools, and it will not be made generally available. New customers will not be able to register the Microsoft.StoragePool resource provider on their subscription and deploy new Disk Pools. Existing subscriptions registered with Microsoft.StoragePool may continue to deploy and manage disk pools for the time being.

\~> Note: Must be either a premium SSD, standard SSD, or an ultra disk in the same region and availability zone as the disk pool.

\~> Note: Ultra disks must have a disk sector size of 512 bytes.

\~> Note: Must be a shared disk, with a maxShares value of two or greater.

\~> Note: You must provide the StoragePool resource provider RBAC permissions to the disks that will be added to the disk pool.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
import * as azuread from "./.gen/providers/azuread";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm, azuread.
For a more precise conversion please use the --provider flag in convert.*/
const roles = ["Disk Pool Operator", "Virtual Machine Contributor"];
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example",
  }
);
const azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
  this,
  "example_1",
  {
    address_space: ["10.0.0.0/16"],
    location: azurermResourceGroupExample.location,
    name: "example-network",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermVirtualNetworkExample.overrideLogicalId("example");
const dataAzureadServicePrincipalExample =
  new azuread.dataAzureadServicePrincipal.DataAzureadServicePrincipal(
    this,
    "example_2",
    {
      display_name: "StoragePool Resource Provider",
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataAzureadServicePrincipalExample.overrideLogicalId("example");
const azurermManagedDiskExample = new azurerm.managedDisk.ManagedDisk(
  this,
  "example_3",
  {
    create_option: "Empty",
    disk_size_gb: 4,
    location: azurermResourceGroupExample.location,
    max_shares: 2,
    name: "example-disk",
    resource_group_name: azurermResourceGroupExample.name,
    storage_account_type: "Premium_LRS",
    zone: "1",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermManagedDiskExample.overrideLogicalId("example");
const azurermRoleAssignmentExample = new azurerm.roleAssignment.RoleAssignment(
  this,
  "example_4",
  {
    principal_id: dataAzureadServicePrincipalExample.id,
    role_definition_name: `\${${roles}[count.index]}`,
    scope: azurermManagedDiskExample.id,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermRoleAssignmentExample.overrideLogicalId("example");
/*In most cases loops should be handled in the programming language context and 
not inside of the Terraform context. If you are looping over something external, e.g. a variable or a file input
you should consider using a for loop. If you are looping over something only known to Terraform, e.g. a result of a data source
you need to keep this like it is.*/
azurermRoleAssignmentExample.addOverride("count", `\${length(${roles})}`);
const azurermSubnetExample = new azurerm.subnet.Subnet(this, "example_5", {
  address_prefixes: ["10.0.0.0/24"],
  delegation: [
    {
      name: "diskspool",
      service_delegation: [
        {
          actions: ["Microsoft.Network/virtualNetworks/read"],
          name: "Microsoft.StoragePool/diskPools",
        },
      ],
    },
  ],
  name: "example-subnet",
  resource_group_name: azurermResourceGroupExample.name,
  virtual_network_name: azurermVirtualNetworkExample.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSubnetExample.overrideLogicalId("example");
const azurermDiskPoolExample = new azurerm.diskPool.DiskPool(
  this,
  "example_6",
  {
    location: azurermResourceGroupExample.location,
    name: "example-pool",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "Basic_B1",
    subnet_id: azurermSubnetExample.id,
    zones: ["1"],
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermDiskPoolExample.overrideLogicalId("example");
const azurermDiskPoolManagedDiskAttachmentExample =
  new azurerm.diskPoolManagedDiskAttachment.DiskPoolManagedDiskAttachment(
    this,
    "example_7",
    {
      depends_on: [`\${${azurermRoleAssignmentExample.fqn}}`],
      disk_pool_id: azurermDiskPoolExample.id,
      managed_disk_id: azurermManagedDiskExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermDiskPoolManagedDiskAttachmentExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • diskPoolId - (Required) The ID of the Disk Pool. Changing this forces a new Disk Pool Managed Disk Attachment to be created.

  • managedDiskId - (Required) The ID of the Managed Disk. Changing this forces a new Disks Pool Managed Disk Attachment to be created.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Disk Pool Managed Disk Attachment.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 60 minutes) Used when creating the Disks Pool Managed Disk Attachment.
  • read - (Defaults to 5 minutes) Used when retrieving the Disks Pool Managed Disk Attachment.
  • delete - (Defaults to 60 minutes) Used when deleting the Disks Pool Managed Disk Attachment.

Import

Disks Pool Managed Disk Attachments can be imported using the resourceId, e.g.

terraform import azurerm_disk_pool_managed_disk_attachment.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.StoragePool/diskPools/storagePool1/managedDisks|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.Compute/disks/disk1