Azure Storage Share File
This page shows how to write Terraform for Storage Share File and write them securely.
azurerm_storage_share_file (Terraform)
The Share File in Storage can be configured in Terraform with the resource name azurerm_storage_share_file
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_storage_share_file" "cert" {
name = "atlantis.crt"
storage_share_id = azurerm_storage_share.share.id
source = var.cert_location
}
resource "azurerm_storage_share_file" "init_cfg" {
name = "init-cfg.txt"
storage_share_id = azurerm_storage_share.this.id
path = azurerm_storage_share_directory.config.name
source = abspath(format("%s/%s", path.module, var.init_cfg_path))
}
resource "azurerm_storage_share_file" "tf-storage-share-file-miguel-1" {
name = "main.tf"
storage_share_id = azurerm_storage_share.tf-storage-file-share-miguel.id
source = "./main.tf"
}
resource "azurerm_storage_share_file" "share_file" {
name = var.settings.name
storage_share_id = var.share_id
path = try(var.settings.path, null)
source = try(var.settings.source, null)
content_type = try(var.settings.content_type, null)
resource "azurerm_storage_share_file" "share_file" {
name = var.settings.name
storage_share_id = var.share_id
path = try(var.settings.path, null)
source = try(var.settings.source, null)
content_type = try(var.settings.content_type, null)
resource "azurerm_storage_share_file" "example" {
name = "my-awesome-content.zip"
storage_share_id = azurerm_storage_share.example.id
source = "some-local-file.zip"
}
resource "azurerm_storage_share_file" "share_file" {
name = var.settings.name
storage_share_id = var.share_id
path = try(var.settings.path, null)
source = try(var.settings.source, null)
content_type = try(var.settings.content_type, null)
resource "azurerm_storage_share_file" "locustfile" {
name = "locustfile.py"
storage_share_id = azurerm_storage_share.locust.id
source = "../locustfile.py"
resource "azurerm_storage_share_file" "locustfile" {
name = "locustfile.py"
storage_share_id = azurerm_storage_share.locust.id
source = "../locustfile.py"
resource "azurerm_storage_share_file" "this" {
name = "requirements.txt"
storage_share_id = azurerm_storage_share.this.id
source = "requirements.txt"
}
Parameters
-
content_disposition
optional - string -
content_encoding
optional - string -
content_md5
optional - string -
content_type
optional - string -
id
optional computed - string -
metadata
optional - map from string to string -
name
required - string -
path
optional - string -
source
optional - string -
storage_share_id
required - string -
timeouts
single block
Explanation in Terraform Registry
Manages a File 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.
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.
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.
Azure Resource Manager Example
Azure Resource Manager code does not have the related resource.
Frequently asked questions
What is Azure Storage Share File?
Azure Storage Share File 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 File?
For Terraform, the johnny-mom/terraform-atlantis-on-aci, Trois-Six/paloalto-automation and mdelacal/terraform-azure source code examples are useful. See the Terraform Example section for further details.