Skip to content

azurermStorageShare

Manages a File Share within Azure Storage.

\~> Note: The storage share supports two storage tiers: premium and standard. Standard file shares are created in general purpose (GPv1 or GPv2) storage accounts and premium file shares are created in FileStorage storage accounts. For further information, refer to the section "What storage tiers are supported in Azure Files?" of documentation.

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 azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "azuretest",
  }
);
const azurermStorageAccountExample = new azurerm.storageAccount.StorageAccount(
  this,
  "example_1",
  {
    account_replication_type: "LRS",
    account_tier: "Standard",
    location: azurermResourceGroupExample.location,
    name: "azureteststorage",
    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.*/
azurermStorageAccountExample.overrideLogicalId("example");
const azurermStorageShareExample = new azurerm.storageShare.StorageShare(
  this,
  "example_2",
  {
    acl: [
      {
        access_policy: [
          {
            expiry: "2019-07-02T10:38:21.0000000Z",
            permissions: "rwdl",
            start: "2019-07-02T09:38:21.0000000Z",
          },
        ],
        id: "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI",
      },
    ],
    name: "sharename",
    quota: 50,
    storage_account_name: azurermStorageAccountExample.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.*/
azurermStorageShareExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the share. Must be unique within the storage account where the share is located. Changing this forces a new resource to be created.

  • storageAccountName - (Required) Specifies the storage account in which to create the share. Changing this forces a new resource to be created.

  • accessTier - (Optional) The access tier of the File Share. Possible values are hot, cool and transactionOptimized, premium.

\~>NOTE: The fileStorage accountKind of the azurermStorageAccount requires premium accessTier.

  • acl - (Optional) One or more acl blocks as defined below.

  • enabledProtocol - (Optional) The protocol used for the share. Possible values are smb and nfs. The smb indicates the share can be accessed by SMBv3.0, SMBv2.1 and REST. The nfs indicates the share can be accessed by NFSv4.1. Defaults to smb. Changing this forces a new resource to be created.

\~>NOTE: The premium SKU of the azurermStorageAccount is required for the nfs protocol.

  • quota - (Required) The maximum size of the share, in gigabytes. For Standard storage accounts, this must be 1GB (or higher) and at most 5120 GB (5 TB). For Premium FileStorage storage accounts, this must be greater than 100 GB and at most 102400 GB (100 TB).

  • metadata - (Optional) A mapping of MetaData for this File Share.


A acl block supports the following:

  • id - (Required) The ID which should be used for this Shared Identifier.

  • accessPolicy - (Optional) An accessPolicy block as defined below.


A accessPolicy block supports the following:

  • permissions - (Required) The permissions which should be associated with this Shared Identifier. Possible value is combination of r (read), w (write), d (delete), and l (list).

\~> Note: Permission order is strict at the service side, and permissions need to be listed in the order above.

  • start - (Optional) The time at which this Access Policy should be valid from, in ISO8601 format.

  • expiry - (Optional) The time at which this Access Policy should be valid until, in ISO8601 format.

Attributes Reference

The following attributes are exported in addition to the arguments listed above:

  • id - The ID of the File Share.

  • resourceManagerId - The Resource Manager ID of this File Share.

  • url - The URL of the File Share

Timeouts

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

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

Import

Storage Shares can be imported using the resourceId, e.g.

terraform import azurerm_storage_share.exampleShare https://account1.file.core.windows.net/share1