Azure Storage Share Directory

This page shows how to write Terraform for Storage Share Directory and write them securely.

azurerm_storage_share_directory (Terraform)

The Share Directory in Storage can be configured in Terraform with the resource name azurerm_storage_share_directory. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

airflow.tf#L77
resource "azurerm_storage_share_directory" "dags" {
  name                 = "dags"
  share_name           = azurerm_storage_share.airflow_share.name
  storage_account_name = module.storage_account.name
}

main.tf#L15
resource "azurerm_storage_share_directory" "config" {
  name                 = "config"
  share_name           = azurerm_storage_share.this.name
  storage_account_name = azurerm_storage_account.this.name
}

storage.tf#L17
resource "azurerm_storage_share_directory" "locust-logs" {
  name                 = "logs"
  share_name           = azurerm_storage_share.locust.name
  storage_account_name = azurerm_storage_account.deployment.name
}

main.tf#L49
resource "azurerm_storage_share_directory" "out_fw_fs_dir" {
  name = element([
    var.palo_fileshare_directories,
    var.palo_fileshare_directories1,
    var.palo_fileshare_directories2,
    var.palo_fileshare_directories3], count.index)
main.tf#L2
resource "azurerm_storage_share_directory" "sh_dir" {
  name                  = var.share_directory_name
  share_name            = var.share_name
  storage_account_name  = var.storage_account_name
}
directory.tf#L1
resource "azurerm_storage_share_directory" "share_directory" {
  name                 = var.settings.name
  share_name           = var.share_name
  storage_account_name = var.storage_account_name
  metadata             = try(var.settings.metadata, null)
main.tf#L35
resource "azurerm_storage_share_directory" "test" {
  name                 = "folder01"
  share_name           = azurerm_storage_share.test.name
  storage_account_name = azurerm_storage_account.test.name
directory.tf#L1
resource "azurerm_storage_share_directory" "share_directory" {
  name                 = var.settings.name
  share_name           = var.share_name
  storage_account_name = var.storage_account_name
  metadata             = try(var.settings.metadata, null)
main.tf#L7
resource "azurerm_storage_share_directory" "this" {
  metadata             = var.metadata
  name                 = var.name
  share_name           = var.share_name
  storage_account_name = var.storage_account_name

main.tf#L7
resource "azurerm_storage_share_directory" "this" {
  metadata             = var.metadata
  name                 = var.name
  share_name           = var.share_name
  storage_account_name = var.storage_account_name

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Directory within an Azure Storage File Share.

Tips: Best Practices for The Other Azure Storage Resources

In addition to the azurerm_storage_account, Azure Storage has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_storage_account

Ensure to use HTTPS connections

It is better to use HTTPS instead of HTTP, which could be vulnerable to person-in-the-middle attacks.

risk-label

azurerm_storage_account_network_rules

Ensure to allow Trusted Microsoft Services to bypass

It is better to allow Trusted Microsoft Services to bypass. They are not able to access storage account unless rules are set to allow them explicitly.

Review your Azure Storage settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Azure Resource Manager Example

Azure Resource Manager code does not have the related resource.

Frequently asked questions

What is Azure Storage Share Directory?

Azure Storage Share Directory is a resource for Storage of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Storage Share Directory?

For Terraform, the blessedwithsins/azure-infra-gs, Trois-Six/paloalto-automation and heoelri/locust-on-aci source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.