Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_storage_blob_inventory_policy - support for deleted blobs in inventory policy via include_deleted property on filters #19286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ func storageBlobInventoryPolicyResourceSchema() map[string]*pluginsdk.Schema {
Default: false,
},

"include_deleted": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},

"include_snapshots": {
Type: pluginsdk.TypeBool,
Optional: true,
Expand Down Expand Up @@ -283,6 +289,7 @@ func expandBlobInventoryPolicyFilter(input []interface{}) *storage.BlobInventory
PrefixMatch: utils.ExpandStringSlice(v["prefix_match"].(*pluginsdk.Set).List()),
BlobTypes: utils.ExpandStringSlice(v["blob_types"].(*pluginsdk.Set).List()),
IncludeBlobVersions: utils.Bool(v["include_blob_versions"].(bool)),
IncludeDeleted: utils.Bool(v["include_deleted"].(bool)),
IncludeSnapshots: utils.Bool(v["include_snapshots"].(bool)),
}
}
Expand Down Expand Up @@ -330,6 +337,10 @@ func flattenBlobInventoryPolicyFilter(input *storage.BlobInventoryPolicyFilter)
if input.IncludeBlobVersions != nil {
includeBlobVersions = *input.IncludeBlobVersions
}
var includeDeleted bool
if input.IncludeDeleted != nil {
includeDeleted = *input.IncludeDeleted
}
var includeSnapshots bool
if input.IncludeSnapshots != nil {
includeSnapshots = *input.IncludeSnapshots
Expand All @@ -338,6 +349,7 @@ func flattenBlobInventoryPolicyFilter(input *storage.BlobInventoryPolicyFilter)
map[string]interface{}{
"blob_types": utils.FlattenStringSlice(input.BlobTypes),
"include_blob_versions": includeBlobVersions,
"include_deleted": includeDeleted,
"include_snapshots": includeSnapshots,
"prefix_match": utils.FlattenStringSlice(input.PrefixMatch),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,13 @@ resource "azurerm_storage_blob_inventory_policy" "test" {
"IsCurrentVersion",
"Snapshot",
"BlobType",
"Deleted",
"RemainingRetentionDays",
]
filter {
blob_types = ["blockBlob", "pageBlob"]
include_blob_versions = true
include_deleted = true
include_snapshots = true
prefix_match = ["*/test"]
}
Expand Down Expand Up @@ -243,10 +246,13 @@ resource "azurerm_storage_blob_inventory_policy" "test" {
"IsCurrentVersion",
"Snapshot",
"BlobType",
"Deleted",
"RemainingRetentionDays",
]
filter {
blob_types = ["blockBlob", "pageBlob"]
include_blob_versions = true
include_deleted = true
include_snapshots = true
prefix_match = ["*/test"]
}
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/storage_blob_inventory_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ A `filter` block supports the following:

~> **NOTE**: The `rules.*.schema_fields` for this rule has to include `IsCurrentVersion` and `VersionId` so that you can specify the `include_blob_versions`.

* `include_deleted` - (Optional) Includes deleted blobs in blob inventory or not? Defaults to `false`.

~> **NOTE:** If `rules.*.scope` is `Container`, the `rules.*.schema_fields` for this rule must include `Deleted`, `Version`, `DeletedTime`, and `RemainingRetentionDays` so that you can specify the `include_deleted`. If `rules.*.scope` is `Blob`, the `rules.*.schema_fields` must include `Deleted` and `RemainingRetentionDays` so that you can specify the `include_deleted`. If `rules.*.scope` is `Blob` and the storage account specified by `storage_account_id` has hierarchical namespaces enabled (`is_hns_enabled` is `true` on the storage account), the `rules.*.schema_fields` for this rule must include `Deleted`, `Version`, `DeletedTime`, and `RemainingRetentionDays` so that you can specify the `include_deleted`.

* `include_snapshots` - (Optional) Includes blob snapshots in blob inventory or not? Defaults to `false`.

~> **NOTE**: The `rules.*.schema_fields` for this rule has to include `Snapshot` so that you can specify the `include_snapshots`.
Expand Down