Skip to content

Commit

Permalink
azurerm_storage_blob_inventory_policy - add exclude_prefixes to `…
Browse files Browse the repository at this point in the history
…filter` resource block (#20281)

Co-authored-by: Harshavardhan Musanalli <[email protected]>
Fixes #20276
  • Loading branch information
harshavmb authored Feb 6, 2023
1 parent 87d3e0a commit e8f5125
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ resource "azurerm_storage_blob_inventory_policy" "test" {
include_deleted = true
include_snapshots = true
prefix_match = ["*/test"]
exclude_prefixes = ["syslog.log"]
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/storage_blob_inventory_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down

0 comments on commit e8f5125

Please sign in to comment.