Skip to content

Commit b78bead

Browse files
committed
identiy and blob properties update
1 parent 9d9becd commit b78bead

File tree

4 files changed

+54
-18
lines changed

4 files changed

+54
-18
lines changed

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Terraform Module to create an Azure storage account with a set of containers (an
44

55
To defines the kind of account, set the argument to `account_kind = "StorageV2"`. Account kind defaults to `StorageV2`. If you want to change this value to other storage accounts kind, then this module automatically computes the appropriate values for `account_tier`, `account_replication_type`. The valid options are `BlobStorage`, `BlockBlobStorage`, `FileStorage`, `Storage` and `StorageV2`. `static_website` can only be set when the account_kind is set to `StorageV2`.
66

7-
> **[NOTE]**
7+
> **[!NOTE]**
88
> **This module now supports the meta arguments including `providers`, `depends_on`, `count`, and `for_each`.**
99
10-
## resources are supported:
10+
## resources are supported
1111

1212
* [Storage Account](https://www.terraform.io/docs/providers/azurerm/r/storage_account.html)
1313
* [Storage Advanced Threat Protection](https://www.terraform.io/docs/providers/azurerm/r/advanced_threat_protection.html)
@@ -75,7 +75,8 @@ module "storage" {
7575

7676
By default, this module will not create a resource group and the name of an existing resource group to be given in an argument `resource_group_name`. If you want to create a new resource group, set the argument `create_resource_group = true`.
7777

78-
*If you are using an existing resource group, then this module uses the same resource group location to create all resources in this module.*
78+
> [!NOTE]
79+
> *If you are using an existing resource group, then this module uses the same resource group location to create all resources in this module.*
7980
8081
## BlockBlobStorage accounts
8182

@@ -107,9 +108,14 @@ This module creates the SMB file shares based on your input within an Azure Stor
107108

108109
## Soft delete for Blob storage
109110

110-
Soft delete protects blob data from being accidentally or erroneously modified or deleted. When soft delete is enabled for a storage account, blobs, blob versions (preview), and snapshots in that storage account may be recovered after they are deleted, within a retention period that you specify.
111+
Soft delete protects blob data from being accidentally or erroneously modified or deleted. When soft delete is enabled for a storage account, containers, blobs, blob versions, and snapshots in that storage account may be recovered after they are deleted, within a retention period that you specify.
111112

112-
This module allows you to specify the number of days that the blob should be retained period using `soft_delete_retention` argument between 1 and 365 days.
113+
This module allows you to specify the number of days that the blob or container should be retained period using `blob_soft_delete_retention_days` and `container_soft_delete_retention_days` arguments between 1 and 365 days. Default is `7` days.
114+
115+
> [!WARNING]
116+
> Container soft delete can restore only whole containers and their contents at the time of deletion. You cannot restore a deleted blob within a container by using container soft delete. Microsoft recommends also enabling blob soft delete and blob versioning to protect individual blobs in a container.
117+
>
118+
> When you restore a container, you must restore it to its original name. If the original name has been used to create a new container, then you will not be able to restore the soft-deleted container.
113119
114120
## Configure Azure Storage firewalls and virtual networks
115121

@@ -185,8 +191,8 @@ module "storage" {
185191
Applying tags to your Azure resources, resource groups, and subscriptions to logically organize them into a taxonomy. Each tag consists of a name and a value pair. For example, you can apply the name `Environment` and the value `Production` to all the resources in production.
186192
For recommendations on how to implement a tagging strategy, see Resource naming and tagging decision guide.
187193

188-
>**Important** :
189-
Tag names are case-insensitive for operations. A tag with a tag name, regardless of the casing, is updated or retrieved. However, the resource provider might keep the casing you provide for the tag name. You'll see that casing in cost reports. **Tag values are case-sensitive.**
194+
> [!IMPORTANT]
195+
> Tag names are case-insensitive for operations. A tag with a tag name, regardless of the casing, is updated or retrieved. However, the resource provider might keep the casing you provide for the tag name. You'll see that casing in cost reports. **Tag values are case-sensitive.**
190196
191197
An effective naming convention assembles resource names by using important resource information as parts of a resource's name. For example, using these [recommended naming conventions](https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/naming-and-tagging#example-names), a public IP resource for a production SharePoint workload is named like this: `pip-sharepoint-prod-westus-001`.
192198

@@ -215,8 +221,11 @@ Name | Description | Type | Default
215221
`skuname`|The SKUs supported by Microsoft Azure Storage. Valid options are Premium_LRS, Premium_ZRS, Standard_GRS, Standard_GZRS, Standard_LRS, Standard_RAGRS, Standard_RAGZRS, Standard_ZRS|string|`Standard_RAGRS`
216222
`access_tier`|Defines the access tier for BlobStorage and StorageV2 accounts. Valid options are Hot and Cool.|string|`"Hot"`
217223
`min_tls_version`|The minimum supported TLS version for the storage account. Possible values are `TLS1_0`, `TLS1_1`, and `TLS1_2` |string|`"TLS1_2"`
218-
`assign_identity`|Set to `true` to enable system-assigned managed identity, or `false` to disable it.|string|`true`
219-
`soft_delete_retention`|Number of retention days for soft delete. If set to null it will disable soft delete all together.|number|`30`
224+
`blob_soft_delete_retention_days`|Specifies the number of days that the blob should be retained, between `1` and `365` days.|number|`7`
225+
`container_soft_delete_retention_days`|Specifies the number of days that the blob should be retained, between `1` and `365` days.|number|`7`
226+
`enable_versioning`|Is versioning enabled?|string|`false`
227+
`last_access_time_enabled`|Is the last access time based tracking enabled?|string|`false`
228+
`change_feed_enabled`|Is the blob service properties for change feed events enabled?|string|`false`
220229
`enable_advanced_threat_protection`|Controls Advance threat protection plan for Storage account!string|`false`
221230
`network_rules`|Configure Azure storage firewalls and virtual networks|list|`null`
222231
`containers_list`| List of container|list|`[]`

examples/complete/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ provider "azurerm" {
55

66
module "storage" {
77
source = "kumarvna/storage/azurerm"
8-
version = "2.3.0"
8+
version = "2.3.0"
99

1010
# By default, this module will not create a resource group
1111
# proivde a name to use an existing resource group, specify the existing resource group name,

main.tf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,20 @@ resource "azurerm_storage_account" "storeacc" {
4545
tags = merge({ "ResourceName" = substr(format("sta%s%s", lower(replace(var.storage_account_name, "/[[:^alnum:]]/", "")), random_string.unique.result), 0, 24) }, var.tags, )
4646

4747
identity {
48-
type = var.assign_identity ? "SystemAssigned" : null
48+
type = var.identity_ids != null ? "SystemAssigned, UserAssigned" : "SystemAssigned"
49+
identity_ids = var.identity_ids
4950
}
5051

5152
blob_properties {
5253
delete_retention_policy {
53-
days = var.soft_delete_retention
54+
days = var.blob_soft_delete_retention_days
5455
}
56+
container_delete_retention_policy {
57+
days = var.container_soft_delete_retention_days
58+
}
59+
versioning_enabled = var.enable_versioning
60+
last_access_time_enabled = var.last_access_time_enabled
61+
change_feed_enabled = var.change_feed_enabled
5562
}
5663

5764
dynamic "network_rules" {

variables.tf

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,29 @@ variable "min_tls_version" {
3838
default = "TLS1_2"
3939
}
4040

41-
variable "assign_identity" {
42-
description = "Set to `true` to enable system-assigned managed identity, or `false` to disable it."
43-
default = true
41+
variable "blob_soft_delete_retention_days" {
42+
description = "Specifies the number of days that the blob should be retained, between `1` and `365` days. Defaults to `7`"
43+
default = 7
4444
}
4545

46-
variable "soft_delete_retention" {
47-
description = "Number of retention days for soft delete. If set to null it will disable soft delete all together."
48-
default = 30
46+
variable "container_soft_delete_retention_days" {
47+
description = "Specifies the number of days that the blob should be retained, between `1` and `365` days. Defaults to `7`"
48+
default = 7
49+
}
50+
51+
variable "enable_versioning" {
52+
description = "Is versioning enabled? Default to `false`"
53+
default = false
54+
}
55+
56+
variable "last_access_time_enabled" {
57+
description = "Is the last access time based tracking enabled? Default to `false`"
58+
default = false
59+
}
60+
61+
variable "change_feed_enabled" {
62+
description = "Is the blob service properties for change feed events enabled?"
63+
default = false
4964
}
5065

5166
variable "enable_advanced_threat_protection" {
@@ -88,6 +103,11 @@ variable "lifecycles" {
88103
default = []
89104
}
90105

106+
variable "identity_ids" {
107+
description = "Specifies a list of user managed identity ids to be assigned. This is required when `type` is set to `UserAssigned` or `SystemAssigned, UserAssigned`"
108+
default = null
109+
}
110+
91111
variable "tags" {
92112
description = "A map of tags to add to all resources"
93113
type = map(string)

0 commit comments

Comments
 (0)