Skip to content

azurermDiskPoolIscsiTarget

Manages an iSCSI Target.

!> 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: Each Disk Pool can have a maximum of 1 iSCSI Target.

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");

Arguments Reference

The following arguments are supported:

  • aclMode - (Required) Mode for Target connectivity. The only supported value is dynamic for now. Changing this forces a new iSCSI Target to be created.

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

  • name - (Required) The name of the iSCSI Target. The name can only contain lowercase letters, numbers, periods, or hyphens, and length should between [5-223]. Changing this forces a new iSCSI Target to be created.

  • targetIqn - (Optional) ISCSI Target IQN (iSCSI Qualified Name); example: iqn200503OrgIscsi:server. IQN should follow the format iqnYyyyMm.<abc>.<pqr>[:xyz]; supported characters include alphanumeric characters in lower case, hyphen, dot and colon, and the length should between 4 and 223. Changing this forces a new iSCSI Target to be created.

Attributes Reference

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

  • id - The ID of the iSCSI Target.

  • endpoints - List of private IPv4 addresses to connect to the iSCSI Target.

  • port - The port used by iSCSI Target portal group.

Timeouts

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

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

Import

iSCSI Targets can be imported using the resourceId, e.g.

terraform import azurerm_disk_pool_iscsi_target.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.StoragePool/diskPools/pool1/iscsiTargets/iscsiTarget1