Skip to content

azurermDiskPoolIscsiTargetLun

Manages an iSCSI Target lun.

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

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");
const azurermDiskPoolIscsiTargetExample =
  new azurerm.diskPoolIscsiTarget.DiskPoolIscsiTarget(this, "example_8", {
    acl_mode: "Dynamic",
    depends_on: [`\${${azurermDiskPoolManagedDiskAttachmentExample.fqn}}`],
    disks_pool_id: azurermDiskPoolExample.id,
    name: "example",
    target_iqn: "iqn.2021-11.com.microsoft:test",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermDiskPoolIscsiTargetExample.overrideLogicalId("example");
const azurermDiskPoolIscsiTargetLunExample =
  new azurerm.diskPoolIscsiTargetLun.DiskPoolIscsiTargetLun(this, "example_9", {
    disk_pool_managed_disk_attachment_id:
      azurermDiskPoolManagedDiskAttachmentExample.id,
    iscsi_target_id: azurermDiskPoolIscsiTargetExample.id,
    name: "example-disk",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermDiskPoolIscsiTargetLunExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • iscsiTargetId - (Required) The ID of the iSCSI Target. Changing this forces a new iSCSI Target LUN to be created.

  • diskPoolManagedDiskAttachmentId - (Required) The ID of the azurermDiskPoolManagedDiskAttachment. Changing this forces a new iSCSI Target LUN to be created.

  • name - (Required) User defined name for iSCSI LUN. Supported characters include uppercase letters, lowercase letters, numbers, periods, underscores or hyphens. Name should end with an alphanumeric character. The length must be between 1 and 90. Changing this forces a new iSCSI Target LUN to be created.

Attributes Reference

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

  • id - The ID of the iSCSI Target LUN.

  • lun - The Logical Unit Number of the iSCSI Target LUN.

Timeouts

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

  • create - (Defaults to 60 minutes) Used when creating the iSCSI Target LUN.
  • read - (Defaults to 5 minutes) Used when retrieving the iSCSI Target LUN.
  • delete - (Defaults to 60 minutes) Used when deleting the iSCSI Target LUN.

Import

iSCSI Target Luns can be imported using the resourceId, e.g.

terraform import azurerm_disk_pool_iscsi_target_lun.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StoragePool/diskPools/diskPoolValue/iscsiTargets/iscsiTargetValue/lun|/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/disks/disk1