azurerm_storage_account

Manages an Azure Storage Account.

Example Usage

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_storage_account" "example" {
  name                     = "storageaccountname"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "GRS"

  tags = {
    environment = "staging"
  }
}

Example Usage with Network Rules

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_virtual_network" "example" {
  name                = "virtnetname"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_subnet" "example" {
  name                 = "subnetname"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.0.2.0/24"]
  service_endpoints    = ["Microsoft.Sql", "Microsoft.Storage"]
}

resource "azurerm_storage_account" "example" {
  name                = "storageaccountname"
  resource_group_name = azurerm_resource_group.example.name

  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"

  network_rules {
    default_action             = "Deny"
    ip_rules                   = ["100.0.0.1"]
    virtual_network_subnet_ids = [azurerm_subnet.example.id]
  }

  tags = {
    environment = "staging"
  }
}

Argument Reference

The following arguments are supported:


A blob_properties block supports the following:


A cors_rule block supports the following:


A custom_domain block supports the following:


A customer_managed_key block supports the following:


A delete_retention_policy block supports the following:


A restore_policy block supports the following:


A container_delete_retention_policy block supports the following:


A hour_metrics block supports the following:


An identity block supports the following:


An immutability_policy block supports the following:


A logging block supports the following:


A minute_metrics block supports the following:


A network_rules block supports the following:


A private_link_access block supports the following:


A azure_files_authentication block supports the following:


A active_directory block supports the following:


A routing block supports the following:


A queue_properties block supports the following:


A sas_policy block supports the following:


A static_website block supports the following:


A share_properties block supports the following:


A retention_policy block supports the following:


A smb block supports the following:


Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:


An identity block exports the following:

Timeouts

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

Import

Storage Accounts can be imported using the resource id, e.g.

terraform import azurerm_storage_account.storageAcc1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Storage/storageAccounts/myaccount