diff --git a/azurerm/internal/services/eventgrid/event_subscription.go b/azurerm/internal/services/eventgrid/event_subscription.go index 8d63682badfe..7eda6a548055 100644 --- a/azurerm/internal/services/eventgrid/event_subscription.go +++ b/azurerm/internal/services/eventgrid/event_subscription.go @@ -279,6 +279,14 @@ func eventSubscriptionSchemaIncludedEventTypes() *pluginsdk.Schema { } } +func eventSubscriptionSchemaEnableAdvancedFilteringOnArrays() *pluginsdk.Schema { + return &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + } +} + func eventSubscriptionSchemaSubjectFilter() *pluginsdk.Schema { return &pluginsdk.Schema{ Type: pluginsdk.TypeList, @@ -991,6 +999,10 @@ func expandEventGridEventSubscriptionFilter(d *pluginsdk.ResourceData) (*eventgr filter.AdvancedFilters = &advancedFilters } + if v, ok := d.GetOk("advanced_filtering_on_arrays_enabled"); ok { + filter.EnableAdvancedFilteringOnArrays = utils.Bool(v.(bool)) + } + return filter, nil } diff --git a/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go b/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go index 23a43ac8a20a..cb4be8b0647e 100644 --- a/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go +++ b/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go @@ -146,6 +146,8 @@ func resourceEventGridEventSubscription() *pluginsdk.Resource { "retry_policy": eventSubscriptionSchemaRetryPolicy(), "labels": eventSubscriptionSchemaLabels(), + + "advanced_filtering_on_arrays_enabled": eventSubscriptionSchemaEnableAdvancedFilteringOnArrays(), }, } } @@ -305,6 +307,7 @@ func resourceEventGridEventSubscriptionRead(d *pluginsdk.ResourceData, meta inte if filter := props.Filter; filter != nil { d.Set("included_event_types", filter.IncludedEventTypes) + d.Set("advanced_filtering_on_arrays_enabled", filter.EnableAdvancedFilteringOnArrays) if err := d.Set("subject_filter", flattenEventGridEventSubscriptionSubjectFilter(filter)); err != nil { return fmt.Errorf("Error setting `subject_filter` for EventGrid Event Subscription %q (Scope %q): %s", id.Name, id.Scope, err) } diff --git a/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource_test.go b/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource_test.go index ad27b7462e05..f36ca630db1d 100644 --- a/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource_test.go +++ b/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource_test.go @@ -150,6 +150,7 @@ func TestAccEventGridEventSubscription_filter(t *testing.T) { check.That(data.ResourceName).Key("included_event_types.1").HasValue("Microsoft.Storage.BlobDeleted"), check.That(data.ResourceName).Key("subject_filter.0.subject_ends_with").HasValue(".jpg"), check.That(data.ResourceName).Key("subject_filter.0.subject_begins_with").HasValue("test/test"), + check.That(data.ResourceName).Key("advanced_filtering_on_arrays_enabled").HasValue("true"), ), }, data.ImportStep(), @@ -489,6 +490,8 @@ resource "azurerm_eventgrid_event_subscription" "test" { queue_name = azurerm_storage_queue.test.name } + advanced_filtering_on_arrays_enabled = true + included_event_types = ["Microsoft.Storage.BlobCreated", "Microsoft.Storage.BlobDeleted"] subject_filter { diff --git a/azurerm/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go b/azurerm/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go index d4e64dffbd05..2a3437c6f97e 100644 --- a/azurerm/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go +++ b/azurerm/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go @@ -124,6 +124,8 @@ func resourceEventGridSystemTopicEventSubscription() *pluginsdk.Resource { "retry_policy": eventSubscriptionSchemaRetryPolicy(), "labels": eventSubscriptionSchemaLabels(), + + "advanced_filtering_on_arrays_enabled": eventSubscriptionSchemaEnableAdvancedFilteringOnArrays(), }, } } @@ -277,6 +279,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData if filter := props.Filter; filter != nil { d.Set("included_event_types", filter.IncludedEventTypes) + d.Set("advanced_filtering_on_arrays_enabled", filter.EnableAdvancedFilteringOnArrays) if err := d.Set("subject_filter", flattenEventGridEventSubscriptionSubjectFilter(filter)); err != nil { return fmt.Errorf("Error setting `subject_filter` for EventGrid System Topic Event Subscription %q (System Topic %q): %s", id.Name, id.SystemTopic, err) } diff --git a/azurerm/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/azurerm/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 3c2287f1bfff..4b0efd467e5e 100644 --- a/azurerm/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/azurerm/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -150,6 +150,7 @@ func TestAccEventGridSystemTopicEventSubscription_filter(t *testing.T) { check.That(data.ResourceName).Key("included_event_types.1").HasValue("Microsoft.Storage.BlobDeleted"), check.That(data.ResourceName).Key("subject_filter.0.subject_ends_with").HasValue(".jpg"), check.That(data.ResourceName).Key("subject_filter.0.subject_begins_with").HasValue("test/test"), + check.That(data.ResourceName).Key("advanced_filtering_on_arrays_enabled").HasValue("true"), ), }, data.ImportStep(), @@ -554,6 +555,8 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { queue_name = azurerm_storage_queue.test.name } + advanced_filtering_on_arrays_enabled = true + included_event_types = ["Microsoft.Storage.BlobCreated", "Microsoft.Storage.BlobDeleted"] subject_filter { diff --git a/website/docs/r/eventgrid_event_subscription.html.markdown b/website/docs/r/eventgrid_event_subscription.html.markdown index 585fa12d8a1f..babffae8282f 100644 --- a/website/docs/r/eventgrid_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_event_subscription.html.markdown @@ -91,6 +91,7 @@ The following arguments are supported: * `labels` - (Optional) A list of labels to assign to the event subscription. +* `advanced_filtering_on_arrays_enabled` - (Optional) Specifies whether advanced filters should be evaluated against an array of values instead of expecting a singular value. Defaults to `false`. --- A `storage_queue_endpoint` supports the following: diff --git a/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown b/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown index 01994998812e..3697b95f61c6 100644 --- a/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown @@ -97,6 +97,8 @@ The following arguments are supported: * `labels` - (Optional) A list of labels to assign to the event subscription. +* `advanced_filtering_on_arrays_enabled` - (Optional) Specifies whether advanced filters should be evaluated against an array of values instead of expecting a singular value. Defaults to `false`. + --- A `storage_queue_endpoint` supports the following: