Azure Storage Share

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

azurerm_storage_share (Terraform)

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

Example Usage from GitHub

main.tf#L31
resource "azurerm_storage_share" "smb1" {
  name                 = "backup"
  storage_account_name = azurerm_storage_account.stga1.name
  quota                = 50
}

resources_storage.tf#L21
resource "azurerm_storage_share" "storageshare_database" {
  name                 = "database"
  storage_account_name = azurerm_storage_account.storageaccount.name
  quota                = 5
}

main.tf#L16
resource "azurerm_storage_share" "file_share" {
  name                 = "online-models"
  storage_account_name = azurerm_storage_account.storage_account.name
  quota = 50  # max size of file_share in Gb
}

main.tf#L29
resource "azurerm_storage_share" "minecraft_world" {
  name                 = "world"
  storage_account_name = azurerm_storage_account.minecraft.name
  quota                = 50
}

storageaccount.tf#L15
resource "azurerm_storage_share" "dags_share" {
  name                 = "airflow-dags"
  storage_account_name = azurerm_storage_account.sa.name
  quota                = 50
}

storage_account.tf#L12
resource "azurerm_storage_share" "config" {
  name                 = "config"
  storage_account_name = azurerm_storage_account.acserver_store.name
  quota                = 10
}

main.tf#L38
resource "azurerm_storage_share" "in_fw_palo_fileshare" {
 name                 = var.in_fw_bootstrap_file_share
 storage_account_name = azurerm_storage_account.fwinbootstrapstor.name
 quota                = 1
}
resource "azurerm_storage_share" "out_fw_palo_fileshare" {
storage.tf#L10
resource "azurerm_storage_share" "homes" {
  name                 = "homes"
  storage_account_name = azurerm_storage_account.homes.name
  quota                = 100
}

sa-blob-file.tf#L25
resource "azurerm_storage_share" "lab" {
  name                 = "terraformshare8023"
  storage_account_name = azurerm_storage_account.lab.name
  quota                = 50
}
main.tf#L25
resource "azurerm_storage_share" "lab" {
  name                 = "terraformshare"
  storage_account_name = azurerm_storage_account.lab.name
  quota                = 50
}

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

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?

Azure Storage Share 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?

For Terraform, the Gabbi68/Infrastructure, cbchalmers/Azure-PaaS-WebApp-Docker-Compose-Wordpress and bchen012/ntu_asr 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.