Skip to content

azurermHpcCacheNfsTarget

Manages a NFS Target within a HPC Cache.

\~> NOTE:: By request of the service team the provider no longer automatically registering the microsoftStorageCache Resource Provider for this resource. To register it you can run azProviderRegisterNamespace 'microsoftStorageCache'.

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";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const customData =
  "#!/bin/bash\nsudo -i \napt-get install -y nfs-kernel-server\nmkdir -p /export/a/1\nmkdir -p /export/a/2\nmkdir -p /export/b\ncat << EOF > /etc/exports\n/export/a *(rw,fsid=0,insecure,no_subtree_check,async)\n/export/b *(rw,fsid=0,insecure,no_subtree_check,async)\nEOF\nsystemctl start nfs-server\nexportfs -arv\n";
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
  this,
  "example_1",
  {
    address_space: ["10.0.0.0/16"],
    location: azurermResourceGroupExample.location,
    name: "examplevn",
    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 azurermSubnetExampleHpc = new azurerm.subnet.Subnet(this, "example_hpc", {
  address_prefixes: ["10.0.1.0/24"],
  name: "examplesubnethpc",
  resource_group_name: azurermResourceGroupExample.name,
  virtual_network_name: azurermVirtualNetworkExample.name,
});
const azurermSubnetExampleVm = new azurerm.subnet.Subnet(this, "example_vm", {
  address_prefixes: ["10.0.2.0/24"],
  name: "examplesubnetvm",
  resource_group_name: azurermResourceGroupExample.name,
  virtual_network_name: azurermVirtualNetworkExample.name,
});
const azurermHpcCacheExample = new azurerm.hpcCache.HpcCache(
  this,
  "example_4",
  {
    cache_size_in_gb: 3072,
    location: azurermResourceGroupExample.location,
    name: "examplehpccache",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "Standard_2G",
    subnet_id: azurermSubnetExampleHpc.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.*/
azurermHpcCacheExample.overrideLogicalId("example");
const azurermNetworkInterfaceExample =
  new azurerm.networkInterface.NetworkInterface(this, "example_5", {
    ip_configuration: [
      {
        name: "internal",
        private_ip_address_allocation: "Dynamic",
        subnet_id: azurermSubnetExampleVm.id,
      },
    ],
    location: azurermResourceGroupExample.location,
    name: "examplenic",
    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.*/
azurermNetworkInterfaceExample.overrideLogicalId("example");
const azurermLinuxVirtualMachineExample =
  new azurerm.linuxVirtualMachine.LinuxVirtualMachine(this, "example_6", {
    admin_ssh_key: [
      {
        public_key: '${file("~/.ssh/id_rsa.pub")}',
        username: "adminuser",
      },
    ],
    admin_username: "adminuser",
    custom_data: `\${base64encode(${customData})}`,
    location: azurermResourceGroupExample.location,
    name: "examplevm",
    network_interface_ids: [azurermNetworkInterfaceExample.id],
    os_disk: [
      {
        caching: "ReadWrite",
        storage_account_type: "Standard_LRS",
      },
    ],
    resource_group_name: azurermResourceGroupExample.name,
    size: "Standard_F2",
    source_image_reference: [
      {
        offer: "UbuntuServer",
        publisher: "Canonical",
        sku: "18.04-LTS",
        version: "latest",
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermLinuxVirtualMachineExample.overrideLogicalId("example");
const azurermHpcCacheNfsTargetExample =
  new azurerm.hpcCacheNfsTarget.HpcCacheNfsTarget(this, "example_7", {
    cache_name: azurermHpcCacheExample.name,
    name: "examplehpcnfstarget",
    namespace_junction: [
      {
        namespace_path: "/nfs/a1",
        nfs_export: "/export/a",
        target_path: "1",
      },
      {
        namespace_path: "/nfs/b",
        nfs_export: "/export/b",
      },
    ],
    resource_group_name: azurermResourceGroupExample.name,
    target_host_name: azurermLinuxVirtualMachineExample.privateIpAddress,
    usage_model: "READ_HEAVY_INFREQ",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermHpcCacheNfsTargetExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the HPC Cache NFS Target. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the Resource Group in which to create the HPC Cache NFS Target. Changing this forces a new resource to be created.

  • cacheName - (Required) The name HPC Cache, which the HPC Cache NFS Target will be added to. Changing this forces a new resource to be created.

  • targetHostName - (Required) The IP address or fully qualified domain name (FQDN) of the HPC Cache NFS target. Changing this forces a new resource to be created.

  • usageModel - (Required) The type of usage of the HPC Cache NFS Target. Possible values are: readHeavyInfreq, readHeavyCheck180, writeWorkload15, writeAround, writeWorkloadCheck30, writeWorkloadCheck60 and writeWorkloadCloudws.

  • namespaceJunction - (Required) Can be specified multiple times to define multiple namespaceJunction. Each namespaceJuntion block supports fields documented below.


A namespaceJunction block supports the following:

  • namespacePath - (Required) The client-facing file path of this NFS target within the HPC Cache NFS Target.

  • nfsExport - (Required) The NFS export of this NFS target within the HPC Cache NFS Target.

  • targetPath - (Optional) The relative subdirectory path from the nfsExport to map to the namespacePath. Defaults to "", in which case the whole nfsExport is exported.

  • accessPolicyName - (Optional) The name of the access policy applied to this target. Defaults to default.

Attributes Reference

The following attributes are exported:

  • id - The ID of the HPC Cache NFS Target.

Timeouts

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

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

Import

NFS Target within a HPC Cache can be imported using the resourceId, e.g.

terraform import azurerm_hpc_cache_nfs_target.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.StorageCache/caches/cache1/storageTargets/target1