From e8f5125f9648c8fab51d6fdc8a5d2ae6d3714618 Mon Sep 17 00:00:00 2001 From: Harshavardhan Musanalli Date: Tue, 7 Feb 2023 00:32:28 +0100 Subject: [PATCH] `azurerm_storage_blob_inventory_policy` - add `exclude_prefixes` to `filter` resource block (#20281) Co-authored-by: Harshavardhan Musanalli Fixes https://github.com/hashicorp/terraform-provider-azurerm/issues/20276 --- .../storage_blob_inventory_policy_resource.go | 13 +++++++++++++ .../storage_blob_inventory_policy_resource_test.go | 1 + .../r/storage_blob_inventory_policy.html.markdown | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/services/storage/storage_blob_inventory_policy_resource.go b/internal/services/storage/storage_blob_inventory_policy_resource.go index c500e934cd2d..05dabab21309 100644 --- a/internal/services/storage/storage_blob_inventory_policy_resource.go +++ b/internal/services/storage/storage_blob_inventory_policy_resource.go @@ -153,6 +153,17 @@ func storageBlobInventoryPolicyResourceSchema() map[string]*pluginsdk.Schema { "prefix_match": { Type: pluginsdk.TypeSet, Optional: true, + MaxItems: 10, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + + "exclude_prefixes": { + Type: pluginsdk.TypeSet, + Optional: true, + MaxItems: 10, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validation.StringIsNotEmpty, @@ -287,6 +298,7 @@ func expandBlobInventoryPolicyFilter(input []interface{}) *storage.BlobInventory v := input[0].(map[string]interface{}) return &storage.BlobInventoryPolicyFilter{ PrefixMatch: utils.ExpandStringSlice(v["prefix_match"].(*pluginsdk.Set).List()), + ExcludePrefix: utils.ExpandStringSlice(v["exclude_prefixes"].(*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)), @@ -352,6 +364,7 @@ func flattenBlobInventoryPolicyFilter(input *storage.BlobInventoryPolicyFilter) "include_deleted": includeDeleted, "include_snapshots": includeSnapshots, "prefix_match": utils.FlattenStringSlice(input.PrefixMatch), + "exclude_prefixes": utils.FlattenStringSlice(input.ExcludePrefix), }, } } diff --git a/internal/services/storage/storage_blob_inventory_policy_resource_test.go b/internal/services/storage/storage_blob_inventory_policy_resource_test.go index a426a8f6dbe0..6da6866c66b1 100644 --- a/internal/services/storage/storage_blob_inventory_policy_resource_test.go +++ b/internal/services/storage/storage_blob_inventory_policy_resource_test.go @@ -219,6 +219,7 @@ resource "azurerm_storage_blob_inventory_policy" "test" { include_deleted = true include_snapshots = true prefix_match = ["*/test"] + exclude_prefixes = ["syslog.log"] } } } diff --git a/website/docs/r/storage_blob_inventory_policy.html.markdown b/website/docs/r/storage_blob_inventory_policy.html.markdown index 7c6a9e66e809..5e8635dcae74 100644 --- a/website/docs/r/storage_blob_inventory_policy.html.markdown +++ b/website/docs/r/storage_blob_inventory_policy.html.markdown @@ -85,7 +85,9 @@ A `filter` block supports the following: ~> **NOTE**: The `rules.*.schema_fields` for this rule has to include `Snapshot` so that you can specify the `include_snapshots`. -* `prefix_match` - (Optional) A set of strings for blob prefixes to be matched. +* `prefix_match` - (Optional) A set of strings for blob prefixes to be matched. Maximum of 10 blob prefixes. + +* `exclude_prefixes` - (Optional) A set of strings for blob prefixes to be excluded. Maximum of 10 blob prefixes. ---