From 6b8dfaec9c70e591b4735433b78fba4be4ab6491 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Feb 2022 16:10:06 -0600 Subject: [PATCH 01/21] add delivery_property --- ...ystem_topic_event_subscription_resource.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go index 0aeccc159ce9..1e6b1a3756c7 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go @@ -129,6 +129,8 @@ func resourceEventGridSystemTopicEventSubscription() *pluginsdk.Resource { "labels": eventSubscriptionSchemaLabels(), "advanced_filtering_on_arrays_enabled": eventSubscriptionSchemaEnableAdvancedFilteringOnArrays(), + + "delivery_property": eventSubscriptionSchemaDeliveryProperty(), }, } } @@ -276,15 +278,34 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData return fmt.Errorf("setting `azure_function_endpoint`: %+v", err) } } + + if azureFunctionEndpoint.DeliveryAttributeMappings != nil { + if err := d.Set("delivery_property", flattenDeliveryProperties(d, azureFunctionEndpoint.DeliveryAttributeMappings)); err != nil { + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "azure_function_endpoint", id.Name, id.Scope, err) + } + } if v, ok := destination.AsEventHubEventSubscriptionDestination(); ok { if err := d.Set("eventhub_endpoint_id", v.ResourceID); err != nil { return fmt.Errorf("setting `eventhub_endpoint_id`: %+v", err) } + + if v.DeliveryAttributeMappings != nil { + if err := d.Set("delivery_property", flattenDeliveryProperties(d, v.DeliveryAttributeMappings)); err != nil { + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "eventhub_endpoint", id.Name, id.Scope, err) + } + } } if v, ok := destination.AsHybridConnectionEventSubscriptionDestination(); ok { if err := d.Set("hybrid_connection_endpoint_id", v.ResourceID); err != nil { return fmt.Errorf("setting `hybrid_connection_endpoint_id`: %+v", err) } + + if v.DeliveryAttributeMappings != nil { + if err := d.Set("delivery_property", flattenDeliveryProperties(d, v.DeliveryAttributeMappings)); err != nil { + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "hybrid_connection_endpoint", id.Name, id.Scope, err) + } + } + } if serviceBusQueueEndpoint, ok := destination.AsServiceBusQueueEventSubscriptionDestination(); ok { if err := d.Set("service_bus_queue_endpoint_id", serviceBusQueueEndpoint.ResourceID); err != nil { @@ -295,6 +316,11 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData if err := d.Set("service_bus_topic_endpoint_id", serviceBusTopicEndpoint.ResourceID); err != nil { return fmt.Errorf("setting `service_bus_topic_endpoint_id`: %+v", err) } + if serviceBusTopicEndpoint.DeliveryAttributeMappings != nil { + if err := d.Set("delivery_property", flattenDeliveryProperties(d, serviceBusTopicEndpoint.DeliveryAttributeMappings)); err != nil { + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "service_bus_topic_endpoint_id", id.Name, id.Scope, err) + } + } } if v, ok := destination.AsStorageQueueEventSubscriptionDestination(); ok { if err := d.Set("storage_queue_endpoint", flattenEventGridEventSubscriptionStorageQueueEndpoint(v)); err != nil { @@ -309,6 +335,11 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData if err := d.Set("webhook_endpoint", flattenEventGridEventSubscriptionWebhookEndpoint(v, &fullURL)); err != nil { return fmt.Errorf("setting `webhook_endpoint`: %+v", err) } + if v.DeliveryAttributeMappings != nil { + if err := d.Set("delivery_property", flattenDeliveryProperties(d, v.DeliveryAttributeMappings)); err != nil { + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "webhook_endpoint", id.Name, id.Scope, err) + } + } } deadLetterDestination := props.DeadLetterDestination From ab32ca4490e36765adb07da88d983135ed7be9ef Mon Sep 17 00:00:00 2001 From: Jack Muskopf Date: Tue, 22 Feb 2022 16:49:57 -0600 Subject: [PATCH 02/21] Remove `Scope` attr --- ...entgrid_system_topic_event_subscription_resource.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go index 1e6b1a3756c7..9da9fdad2bc9 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go @@ -281,7 +281,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData if azureFunctionEndpoint.DeliveryAttributeMappings != nil { if err := d.Set("delivery_property", flattenDeliveryProperties(d, azureFunctionEndpoint.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "azure_function_endpoint", id.Name, id.Scope, err) + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "azure_function_endpoint", id.Name, err) } } if v, ok := destination.AsEventHubEventSubscriptionDestination(); ok { @@ -291,7 +291,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData if v.DeliveryAttributeMappings != nil { if err := d.Set("delivery_property", flattenDeliveryProperties(d, v.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "eventhub_endpoint", id.Name, id.Scope, err) + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "eventhub_endpoint", id.Name, err) } } } @@ -302,7 +302,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData if v.DeliveryAttributeMappings != nil { if err := d.Set("delivery_property", flattenDeliveryProperties(d, v.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "hybrid_connection_endpoint", id.Name, id.Scope, err) + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "hybrid_connection_endpoint", id.Name, err) } } @@ -318,7 +318,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData } if serviceBusTopicEndpoint.DeliveryAttributeMappings != nil { if err := d.Set("delivery_property", flattenDeliveryProperties(d, serviceBusTopicEndpoint.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "service_bus_topic_endpoint_id", id.Name, id.Scope, err) + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "service_bus_topic_endpoint_id", id.Name, err) } } } @@ -337,7 +337,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData } if v.DeliveryAttributeMappings != nil { if err := d.Set("delivery_property", flattenDeliveryProperties(d, v.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q (Scope %q): %s", "webhook_endpoint", id.Name, id.Scope, err) + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "webhook_endpoint", id.Name, err) } } } From 570de4dff0401051973406e007a0e84c33fa88c1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Feb 2022 08:35:57 -0600 Subject: [PATCH 03/21] fix azureFunctionEndpoint stmt and field Name -> EventSubscriptionName --- ..._system_topic_event_subscription_resource.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go index 9da9fdad2bc9..59f673786ad5 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource.go @@ -277,11 +277,10 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData if err := d.Set("azure_function_endpoint", flattenEventGridEventSubscriptionAzureFunctionEndpoint(azureFunctionEndpoint)); err != nil { return fmt.Errorf("setting `azure_function_endpoint`: %+v", err) } - } - - if azureFunctionEndpoint.DeliveryAttributeMappings != nil { - if err := d.Set("delivery_property", flattenDeliveryProperties(d, azureFunctionEndpoint.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "azure_function_endpoint", id.Name, err) + if azureFunctionEndpoint.DeliveryAttributeMappings != nil { + if err := d.Set("delivery_property", flattenDeliveryProperties(d, azureFunctionEndpoint.DeliveryAttributeMappings)); err != nil { + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "azure_function_endpoint", id.EventSubscriptionName, err) + } } } if v, ok := destination.AsEventHubEventSubscriptionDestination(); ok { @@ -291,7 +290,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData if v.DeliveryAttributeMappings != nil { if err := d.Set("delivery_property", flattenDeliveryProperties(d, v.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "eventhub_endpoint", id.Name, err) + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "eventhub_endpoint", id.EventSubscriptionName, err) } } } @@ -302,7 +301,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData if v.DeliveryAttributeMappings != nil { if err := d.Set("delivery_property", flattenDeliveryProperties(d, v.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "hybrid_connection_endpoint", id.Name, err) + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "hybrid_connection_endpoint", id.EventSubscriptionName, err) } } @@ -318,7 +317,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData } if serviceBusTopicEndpoint.DeliveryAttributeMappings != nil { if err := d.Set("delivery_property", flattenDeliveryProperties(d, serviceBusTopicEndpoint.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "service_bus_topic_endpoint_id", id.Name, err) + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "service_bus_topic_endpoint_id", id.EventSubscriptionName, err) } } } @@ -337,7 +336,7 @@ func resourceEventGridSystemTopicEventSubscriptionRead(d *pluginsdk.ResourceData } if v.DeliveryAttributeMappings != nil { if err := d.Set("delivery_property", flattenDeliveryProperties(d, v.DeliveryAttributeMappings)); err != nil { - return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "webhook_endpoint", id.Name, err) + return fmt.Errorf("setting `%q` for EventGrid SystemTopic delivery properties %q: %s", "webhook_endpoint", id.EventSubscriptionName, err) } } } From ac82485b20fa39bede0c82acd436ecc193b9197e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Mar 2022 17:10:11 -0600 Subject: [PATCH 04/21] static test --- ..._topic_event_subscription_resource_test.go | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 5b4eeb205f2d..aa7451c16912 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -266,6 +266,31 @@ func TestAccEventGridSystemTopicEventSubscription_userIdentity(t *testing.T) { }) } +func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesStatic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") + r := EventGridEventSubscriptionResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.deliveryProperties(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + + check.That(data.ResourceName).Key("delivery_property.0.header_name").HasValue("test-1"), + check.That(data.ResourceName).Key("delivery_property.0.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.0.value").HasValue("1"), + check.That(data.ResourceName).Key("delivery_property.0.secret").HasValue("false"), + + check.That(data.ResourceName).Key("delivery_property.1.header_name").HasValue("test-2"), + check.That(data.ResourceName).Key("delivery_property.1.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.1.value").HasValue("string"), + check.That(data.ResourceName).Key("delivery_property.1.secret").HasValue("false"), + ), + }, + data.ImportStep(), + }) +} + func (EventGridSystemTopicEventSubscriptionResource) Exists(ctx context.Context, clients *clients.Client, state *terraform.InstanceState) (*bool, error) { id, err := parse.SystemTopicEventSubscriptionID(state.ID) if err != nil { @@ -1266,3 +1291,67 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomString) } + +func (EventGridEventSubscriptionResource) deliveryProperties(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-eg-%[1]d" + location = "%[2]s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestacc%[3]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" + + tags = { + environment = "staging" + } +} + +resource "azurerm_storage_queue" "test" { + name = "mysamplequeue-%[1]d" + storage_account_name = azurerm_storage_account.test.name +} + +resource "azurerm_eventgrid_system_topic" "test" { + name = "acctesteg-%[1]d" + location = "Global" + resource_group_name = azurerm_resource_group.test.name + source_arm_resource_id = azurerm_resource_group.test.id + topic_type = "Microsoft.Resources.ResourceGroups" +} + +resource "azurerm_eventgrid_system_topic_event_subscription" "test" { + name = "acctesteg-%[1]d" + system_topic = azurerm_eventgrid_system_topic.test.name + resource_group_name = azurerm_resource_group.test.name + + storage_queue_endpoint { + storage_account_id = azurerm_storage_account.test.id + queue_name = azurerm_storage_queue.test.name + } + + delivery_property { + header_name = "test-1" + type = "Static" + value = "1" + secret = false + } + + delivery_property { + header_name = "test-2" + type = "Static" + value = "string" + secret = false + } + +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) +} \ No newline at end of file From 2f5fb7a320e14d390e99dc74eb90cafc45e68f55 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Mar 2022 17:19:09 -0600 Subject: [PATCH 05/21] mixed test --- ..._topic_event_subscription_resource_test.go | 103 +++++++++++++++++- 1 file changed, 101 insertions(+), 2 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index aa7451c16912..1ac338ec69b5 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -268,7 +268,7 @@ func TestAccEventGridSystemTopicEventSubscription_userIdentity(t *testing.T) { func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesStatic(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") - r := EventGridEventSubscriptionResource{} + r := EventGridSystemTopicEventSubscriptionResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { @@ -291,6 +291,36 @@ func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesStatic(t *te }) } + +func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesMixed(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") + r := EventGridSystemTopicEventSubscriptionResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.deliveryPropertiesWithMultipleTypes(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + + check.That(data.ResourceName).Key("delivery_property.0.header_name").HasValue("test-static-1"), + check.That(data.ResourceName).Key("delivery_property.0.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.0.value").HasValue("1"), + check.That(data.ResourceName).Key("delivery_property.0.secret").HasValue("false"), + + check.That(data.ResourceName).Key("delivery_property.1.header_name").HasValue("test-dynamic-1"), + check.That(data.ResourceName).Key("delivery_property.1.type").HasValue("Dynamic"), + check.That(data.ResourceName).Key("delivery_property.1.source_field").HasValue("data.system"), + + check.That(data.ResourceName).Key("delivery_property.2.header_name").HasValue("test-secret-1"), + check.That(data.ResourceName).Key("delivery_property.2.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.2.secret").HasValue("true"), + check.That(data.ResourceName).Key("delivery_property.2.value").HasValue("this-value-is-secret!"), + ), + }, + data.ImportStep("delivery_property.2.value"), + }) +} + func (EventGridSystemTopicEventSubscriptionResource) Exists(ctx context.Context, clients *clients.Client, state *terraform.InstanceState) (*bool, error) { id, err := parse.SystemTopicEventSubscriptionID(state.ID) if err != nil { @@ -1292,7 +1322,7 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString) } -func (EventGridEventSubscriptionResource) deliveryProperties(data acceptance.TestData) string { +func (EventGridSystemTopicEventSubscriptionResource) deliveryProperties(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -1354,4 +1384,73 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomString) +} + +func (EventGridSystemTopicEventSubscriptionResource) deliveryPropertiesWithMultipleTypes(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-eg-%[1]d" + location = "%[2]s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestacc%[3]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" + + tags = { + environment = "staging" + } +} + +resource "azurerm_storage_queue" "test" { + name = "mysamplequeue-%[1]d" + storage_account_name = azurerm_storage_account.test.name +} + +resource "azurerm_eventgrid_system_topic" "test" { + name = "acctesteg-%[1]d" + location = "Global" + resource_group_name = azurerm_resource_group.test.name + source_arm_resource_id = azurerm_resource_group.test.id + topic_type = "Microsoft.Resources.ResourceGroups" +} + +resource "azurerm_eventgrid_system_topic_event_subscription" "test" { + name = "acctesteg-%[1]d" + system_topic = azurerm_eventgrid_system_topic.test.name + resource_group_name = azurerm_resource_group.test.name + + storage_queue_endpoint { + storage_account_id = azurerm_storage_account.test.id + queue_name = azurerm_storage_queue.test.name + } + + delivery_property { + header_name = "test-static-1" + type = "Static" + value = "1" + secret = false + } + + delivery_property { + header_name = "test-dynamic-1" + type = "Dynamic" + source_field = "data.system" + } + + delivery_property { + header_name = "test-secret-1" + type = "Static" + value = "this-value-is-secret!" + secret = true + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) } \ No newline at end of file From 57fc70ea5b56ca43a4ff983a40a1d48f53ae27ce Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Mar 2022 17:30:02 -0600 Subject: [PATCH 06/21] docs --- ...system_topic_event_subscription.html.markdown | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 47f03dfc8c72..aceaea13e527 100644 --- a/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown @@ -93,6 +93,8 @@ The following arguments are supported: * `delivery_identity` - (Optional) A `delivery_identity` block as defined below. +* `delivery_property` - (Optional) A `delivery_property` block as defined below. + * `dead_letter_identity` - (Optional) A `dead_letter_identity` block as defined below. -> **Note:** `storage_blob_dead_letter_destination` must be specified when a `dead_letter_identity` is specified @@ -197,6 +199,20 @@ A `delivery_identity` supports the following: --- +A `delivery_property` supports the following: + +* `header_name` - (Required) The name of the header to send on to the destination + +* `type` - (Required) Either `Static` or `Dynamic` + +* `value` - (Optional) If the `type` is `Static`, then provide the value to use + +* `source_field` - (Optional) If the `type` is `Dynamic`, then provide the payload field to be used as the value. Valid source fields differ by subscription type. + +* `secret` - (Optional) True if the `value` is a secret and should be protected, otherwise false. If True, then this value won't be returned from Azure API calls + +--- + A `dead_letter_identity` supports the following: * `type` - (Required) Specifies the type of Managed Service Identity that is used for dead lettering. Allowed value is `SystemAssigned`, `UserAssigned`. From a2ccb5122bb28f4b23278f978117667a6aa41428 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Mar 2022 17:37:32 -0600 Subject: [PATCH 07/21] secret --- ..._topic_event_subscription_resource_test.go | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 1ac338ec69b5..29fe5bb38d6b 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -291,6 +291,24 @@ func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesStatic(t *te }) } +func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesSecret(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") + r := EventGridSystemTopicEventSubscriptionResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.deliveryPropertiesSecret(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + + check.That(data.ResourceName).Key("delivery_property.0.header_name").HasValue("test-secret-1"), + check.That(data.ResourceName).Key("delivery_property.0.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.0.secret").HasValue("true"), + ), + }, + data.ImportStep("delivery_property.0.value"), + }) +} func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesMixed(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") @@ -1386,6 +1404,62 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString) } +func (EventGridSystemTopicEventSubscriptionResource) deliveryPropertiesSecret(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-eg-%[1]d" + location = "%[2]s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestacc%[3]s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" + + tags = { + environment = "staging" + } +} + +resource "azurerm_storage_queue" "test" { + name = "mysamplequeue-%[1]d" + storage_account_name = azurerm_storage_account.test.name +} + +resource "azurerm_eventgrid_system_topic" "test" { + name = "acctesteg-%[1]d" + location = "Global" + resource_group_name = azurerm_resource_group.test.name + source_arm_resource_id = azurerm_resource_group.test.id + topic_type = "Microsoft.Resources.ResourceGroups" +} + +resource "azurerm_eventgrid_system_topic_event_subscription" "test" { + name = "acctesteg-%[1]d" + system_topic = azurerm_eventgrid_system_topic.test.name + resource_group_name = azurerm_resource_group.test.name + + storage_queue_endpoint { + storage_account_id = azurerm_storage_account.test.id + queue_name = azurerm_storage_queue.test.name + } + + delivery_property { + header_name = "test-secret-1" + type = "Static" + value = "1" + secret = true + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) +} + func (EventGridSystemTopicEventSubscriptionResource) deliveryPropertiesWithMultipleTypes(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { From 0db582e09a666fd553fa8293952c1c49932c0f40 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Mar 2022 08:30:10 -0600 Subject: [PATCH 08/21] use service bus --- ..._topic_event_subscription_resource_test.go | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 29fe5bb38d6b..37034501f822 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -1351,21 +1351,18 @@ resource "azurerm_resource_group" "test" { location = "%[2]s" } -resource "azurerm_storage_account" "test" { - name = "acctestacc%[3]s" - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - account_tier = "Standard" - account_replication_type = "LRS" - - tags = { - environment = "staging" - } +resource "azurerm_servicebus_namespace" "example" { + name = "acctestservicebusnamespace-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard" } -resource "azurerm_storage_queue" "test" { - name = "mysamplequeue-%[1]d" - storage_account_name = azurerm_storage_account.test.name +resource "azurerm_servicebus_topic" "test" { + name = "acctestservicebustopic-%[1]d" + resource_group_name = azurerm_resource_group.test.name + namespace_name = azurerm_servicebus_namespace.example.name + enable_partitioning = true } resource "azurerm_eventgrid_system_topic" "test" { @@ -1381,9 +1378,12 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { system_topic = azurerm_eventgrid_system_topic.test.name resource_group_name = azurerm_resource_group.test.name - storage_queue_endpoint { - storage_account_id = azurerm_storage_account.test.id - queue_name = azurerm_storage_queue.test.name + service_bus_topic_endpoint_id = azurerm_servicebus_topic.test.id + + advanced_filtering_on_arrays_enabled = true + + subject_filter { + subject_begins_with = "test/test" } delivery_property { From f3cbe45342b1e08e691a5d9b105ae82acd5a0fed Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Mar 2022 09:12:18 -0600 Subject: [PATCH 09/21] update, eventhub, hybrid --- ..._topic_event_subscription_resource_test.go | 315 ++++++++++++++++-- 1 file changed, 282 insertions(+), 33 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 37034501f822..79363b2fffda 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -339,6 +339,88 @@ func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesMixed(t *tes }) } +func TestAccEventGridEventSubscription_deliveryPropertiesUpdate(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") + r := EventGridSystemTopicEventSubscriptionResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.deliveryPropertiesWithMultipleTypes(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("delivery_property.0.header_name").HasValue("test-static-1"), + check.That(data.ResourceName).Key("delivery_property.0.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.0.value").HasValue("1"), + check.That(data.ResourceName).Key("delivery_property.0.secret").HasValue("false"), + check.That(data.ResourceName).Key("delivery_property.1.header_name").HasValue("test-dynamic-1"), + check.That(data.ResourceName).Key("delivery_property.1.type").HasValue("Dynamic"), + check.That(data.ResourceName).Key("delivery_property.1.source_field").HasValue("data.system"), + check.That(data.ResourceName).Key("delivery_property.2.header_name").HasValue("test-secret-1"), + check.That(data.ResourceName).Key("delivery_property.2.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.2.secret").HasValue("true"), + check.That(data.ResourceName).Key("delivery_property.2.value").HasValue("this-value-is-secret!"), + ), + }, + { + Config: r.deliveryPropertiesUpdate(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("delivery_property.0.header_name").HasValue("test-static-1"), + check.That(data.ResourceName).Key("delivery_property.0.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.0.value").HasValue("2"), + check.That(data.ResourceName).Key("delivery_property.0.secret").HasValue("false"), + check.That(data.ResourceName).Key("delivery_property.1.header_name").HasValue("test-dynamic-1"), + check.That(data.ResourceName).Key("delivery_property.1.type").HasValue("Dynamic"), + check.That(data.ResourceName).Key("delivery_property.1.source_field").HasValue("data.topic"), + check.That(data.ResourceName).Key("delivery_property.2.header_name").HasValue("test-secret-1"), + check.That(data.ResourceName).Key("delivery_property.2.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.2.secret").HasValue("true"), + check.That(data.ResourceName).Key("delivery_property.2.value").HasValue("this-value-is-still-secret!"), + ), + }, + }) +} + +func TestAccEventGridEventSubscription_deliveryPropertiesForEventHubs(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") + r := EventGridSystemTopicEventSubscriptionResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.deliveryPropertiesForEventHubs(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + + check.That(data.ResourceName).Key("delivery_property.0.header_name").HasValue("test-static-1"), + check.That(data.ResourceName).Key("delivery_property.0.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.0.value").HasValue("1"), + check.That(data.ResourceName).Key("delivery_property.0.secret").HasValue("false"), + ), + }, + data.ImportStep(), + }) +} + +func TestAccEventGridEventSubscription_deliveryPropertiesHybridRelay(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") + r := EventGridSystemTopicEventSubscriptionResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.deliveryPropertiesForHybridRelay(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + + check.That(data.ResourceName).Key("delivery_property.0.header_name").HasValue("test-static-1"), + check.That(data.ResourceName).Key("delivery_property.0.type").HasValue("Static"), + check.That(data.ResourceName).Key("delivery_property.0.value").HasValue("1"), + check.That(data.ResourceName).Key("delivery_property.0.secret").HasValue("false"), + ), + }, + data.ImportStep(), + }) +} + func (EventGridSystemTopicEventSubscriptionResource) Exists(ctx context.Context, clients *clients.Client, state *terraform.InstanceState) (*bool, error) { id, err := parse.SystemTopicEventSubscriptionID(state.ID) if err != nil { @@ -1415,21 +1497,18 @@ resource "azurerm_resource_group" "test" { location = "%[2]s" } -resource "azurerm_storage_account" "test" { - name = "acctestacc%[3]s" - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - account_tier = "Standard" - account_replication_type = "LRS" - - tags = { - environment = "staging" - } +resource "azurerm_servicebus_namespace" "example" { + name = "acctestservicebusnamespace-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard" } -resource "azurerm_storage_queue" "test" { - name = "mysamplequeue-%[1]d" - storage_account_name = azurerm_storage_account.test.name +resource "azurerm_servicebus_topic" "test" { + name = "acctestservicebustopic-%[1]d" + resource_group_name = azurerm_resource_group.test.name + namespace_name = azurerm_servicebus_namespace.example.name + enable_partitioning = true } resource "azurerm_eventgrid_system_topic" "test" { @@ -1445,9 +1524,12 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { system_topic = azurerm_eventgrid_system_topic.test.name resource_group_name = azurerm_resource_group.test.name - storage_queue_endpoint { - storage_account_id = azurerm_storage_account.test.id - queue_name = azurerm_storage_queue.test.name + service_bus_topic_endpoint_id = azurerm_servicebus_topic.test.id + + advanced_filtering_on_arrays_enabled = true + + subject_filter { + subject_begins_with = "test/test" } delivery_property { @@ -1471,21 +1553,18 @@ resource "azurerm_resource_group" "test" { location = "%[2]s" } -resource "azurerm_storage_account" "test" { - name = "acctestacc%[3]s" - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - account_tier = "Standard" - account_replication_type = "LRS" - - tags = { - environment = "staging" - } +resource "azurerm_servicebus_namespace" "example" { + name = "acctestservicebusnamespace-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard" } -resource "azurerm_storage_queue" "test" { - name = "mysamplequeue-%[1]d" - storage_account_name = azurerm_storage_account.test.name +resource "azurerm_servicebus_topic" "test" { + name = "acctestservicebustopic-%[1]d" + resource_group_name = azurerm_resource_group.test.name + namespace_name = azurerm_servicebus_namespace.example.name + enable_partitioning = true } resource "azurerm_eventgrid_system_topic" "test" { @@ -1501,9 +1580,12 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { system_topic = azurerm_eventgrid_system_topic.test.name resource_group_name = azurerm_resource_group.test.name - storage_queue_endpoint { - storage_account_id = azurerm_storage_account.test.id - queue_name = azurerm_storage_queue.test.name + service_bus_topic_endpoint_id = azurerm_servicebus_topic.test.id + + advanced_filtering_on_arrays_enabled = true + + subject_filter { + subject_begins_with = "test/test" } delivery_property { @@ -1527,4 +1609,171 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { } } `, data.RandomInteger, data.Locations.Primary, data.RandomString) -} \ No newline at end of file +} + +func (EventGridEventSubscriptionResource) deliveryPropertiesUpdate(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-eg-%[1]d" + location = "%[2]s" +} + +resource "azurerm_servicebus_namespace" "example" { + name = "acctestservicebusnamespace-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard" +} + +resource "azurerm_servicebus_topic" "test" { + name = "acctestservicebustopic-%[1]d" + resource_group_name = azurerm_resource_group.test.name + namespace_name = azurerm_servicebus_namespace.example.name + enable_partitioning = true +} + +resource "azurerm_eventgrid_system_topic" "test" { + name = "acctesteg-%[1]d" + location = "Global" + resource_group_name = azurerm_resource_group.test.name + source_arm_resource_id = azurerm_resource_group.test.id + topic_type = "Microsoft.Resources.ResourceGroups" +} + +resource "azurerm_eventgrid_system_topic_event_subscription" "test" { + name = "acctesteg-%[1]d" + system_topic = azurerm_eventgrid_system_topic.test.name + resource_group_name = azurerm_resource_group.test.name + + service_bus_topic_endpoint_id = azurerm_servicebus_topic.test.id + + advanced_filtering_on_arrays_enabled = true + + subject_filter { + subject_begins_with = "test/test" + } + + delivery_property { + header_name = "test-static-1" + type = "Static" + value = "2" + secret = false + } + + delivery_property { + header_name = "test-dynamic-1" + type = "Dynamic" + source_field = "data.topic" + } + + delivery_property { + header_name = "test-secret-1" + type = "Static" + value = "this-value-is-still-secret!" + secret = true + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) +} + +func (EventGridEventSubscriptionResource) deliveryPropertiesForEventHubs(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-eg-%[1]d" + location = "%[2]s" +} + +resource "azurerm_eventhub_namespace" "test" { + name = "acctesteventhubnamespace-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Basic" +} + +resource "azurerm_eventhub" "test" { + name = "acctesteventhub-%[1]d" + namespace_name = azurerm_eventhub_namespace.test.name + resource_group_name = azurerm_resource_group.test.name + partition_count = 2 + message_retention = 1 +} + +resource "azurerm_eventgrid_system_topic" "test" { + name = "acctesteg-%[1]d" + location = "Global" + resource_group_name = azurerm_resource_group.test.name + source_arm_resource_id = azurerm_resource_group.test.id + topic_type = "Microsoft.Resources.ResourceGroups" +} + +resource "azurerm_eventgrid_system_topic_event_subscription" "test" { + name = "acctesteg-%[1]d" + system_topic = azurerm_eventgrid_system_topic.test.name + resource_group_name = azurerm_resource_group.test.name + + eventhub_endpoint_id = azurerm_eventhub.test.id + + delivery_property { + header_name = "test-static-1" + type = "Static" + value = "1" + } +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (EventGridEventSubscriptionResource) deliveryPropertiesForHybridRelay(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-eg-%[1]d" + location = "%[2]s" +} + +resource "azurerm_relay_namespace" "test" { + name = "acctest-%[1]d-rly-eventsub-repo" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + sku_name = "Standard" +} + +resource "azurerm_relay_hybrid_connection" "test" { + name = "acctest-%[1]d-rhc-eventsub-repo" + resource_group_name = azurerm_resource_group.test.name + relay_namespace_name = azurerm_relay_namespace.test.name + requires_client_authorization = false +} + +resource "azurerm_eventgrid_system_topic" "test" { + name = "acctesteg-%[1]d" + location = "Global" + resource_group_name = azurerm_resource_group.test.name + source_arm_resource_id = azurerm_resource_group.test.id + topic_type = "Microsoft.Resources.ResourceGroups" +} + +resource "azurerm_eventgrid_system_topic_event_subscription" "test" { + name = "acctesteg-%[1]d" + system_topic = azurerm_eventgrid_system_topic.test.name + resource_group_name = azurerm_resource_group.test.name + + delivery_property { + header_name = "test-static-1" + type = "Static" + value = "1" + } +} +`, data.RandomInteger, data.Locations.Primary) +} From ac2bd786a543f4869c27f0763661bd0078ff1516 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Mar 2022 09:17:36 -0600 Subject: [PATCH 10/21] fix class and method names --- ..._system_topic_event_subscription_resource_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 79363b2fffda..b12740929b3c 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -339,7 +339,7 @@ func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesMixed(t *tes }) } -func TestAccEventGridEventSubscription_deliveryPropertiesUpdate(t *testing.T) { +func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesUpdate(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") r := EventGridSystemTopicEventSubscriptionResource{} @@ -381,7 +381,7 @@ func TestAccEventGridEventSubscription_deliveryPropertiesUpdate(t *testing.T) { }) } -func TestAccEventGridEventSubscription_deliveryPropertiesForEventHubs(t *testing.T) { +func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesForEventHubs(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") r := EventGridSystemTopicEventSubscriptionResource{} @@ -401,7 +401,7 @@ func TestAccEventGridEventSubscription_deliveryPropertiesForEventHubs(t *testing }) } -func TestAccEventGridEventSubscription_deliveryPropertiesHybridRelay(t *testing.T) { +func TestAccEventGridSystemTopicEventSubscription_deliveryPropertiesHybridRelay(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_eventgrid_system_topic_event_subscription", "test") r := EventGridSystemTopicEventSubscriptionResource{} @@ -1611,7 +1611,7 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString) } -func (EventGridEventSubscriptionResource) deliveryPropertiesUpdate(data acceptance.TestData) string { +func (EventGridSystemTopicEventSubscriptionResource) deliveryPropertiesUpdate(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -1680,7 +1680,7 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString) } -func (EventGridEventSubscriptionResource) deliveryPropertiesForEventHubs(data acceptance.TestData) string { +func (EventGridSystemTopicEventSubscriptionResource) deliveryPropertiesForEventHubs(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -1730,7 +1730,7 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { `, data.RandomInteger, data.Locations.Primary) } -func (EventGridEventSubscriptionResource) deliveryPropertiesForHybridRelay(data acceptance.TestData) string { +func (EventGridSystemTopicEventSubscriptionResource) deliveryPropertiesForHybridRelay(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} From 98f05a8e2df7de89e4a8f9573fb3e06979921686 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Mar 2022 09:27:56 -0600 Subject: [PATCH 11/21] eventhub_endpoint block dne, but azure_function_endpoint can be defined; add relevant endpoint note --- .../r/eventgrid_system_topic_event_subscription.html.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 aceaea13e527..6c94c7cc227b 100644 --- a/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown @@ -83,7 +83,7 @@ The following arguments are supported: * `webhook_endpoint` - (Optional) A `webhook_endpoint` block as defined below. -~> **NOTE:** One of `eventhub_endpoint`, `eventhub_endpoint_id`, `hybrid_connection_endpoint`, `hybrid_connection_endpoint_id`, `service_bus_queue_endpoint_id`, `service_bus_topic_endpoint_id`, `storage_queue_endpoint` or `webhook_endpoint` must be specified. +~> **NOTE:** One of `azure_function_endpoint`, `eventhub_endpoint_id`, `hybrid_connection_endpoint`, `hybrid_connection_endpoint_id`, `service_bus_queue_endpoint_id`, `service_bus_topic_endpoint_id`, `storage_queue_endpoint` or `webhook_endpoint` must be specified. * `included_event_types` - (Optional) A list of applicable event types that need to be part of the event subscription. @@ -201,6 +201,8 @@ A `delivery_identity` supports the following: A `delivery_property` supports the following: +~> **NOTE:** `delivery_property` blocks are only effective when using an `azure_function_endpoint`, `eventhub_endpoint_id`, `hybrid_connection_endpoint_id`, `service_bus_topic_endpoint_id`, or `webhook_endpoint` endpoint specification. + * `header_name` - (Required) The name of the header to send on to the destination * `type` - (Required) Either `Static` or `Dynamic` From d91158ebb1cbb4662d8de740b125977d83e4fa8b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Mar 2022 09:42:30 -0600 Subject: [PATCH 12/21] add hybrid connection id --- .../eventgrid_system_topic_event_subscription_resource_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index b12740929b3c..9551066f12cc 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -1769,6 +1769,8 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { system_topic = azurerm_eventgrid_system_topic.test.name resource_group_name = azurerm_resource_group.test.name + hybrid_connection_endpoint_id = azurerm_relay_hybrid_connection.test.id + delivery_property { header_name = "test-static-1" type = "Static" From 21a196f1cd8a39d50df56b5a0f040cecf2557eb9 Mon Sep 17 00:00:00 2001 From: Jack Muskopf Date: Mon, 7 Mar 2022 10:04:35 -0600 Subject: [PATCH 13/21] Add period to end of description Co-authored-by: stephybun --- .../r/eventgrid_system_topic_event_subscription.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6c94c7cc227b..c97dd7ea966d 100644 --- a/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown @@ -203,7 +203,7 @@ A `delivery_property` supports the following: ~> **NOTE:** `delivery_property` blocks are only effective when using an `azure_function_endpoint`, `eventhub_endpoint_id`, `hybrid_connection_endpoint_id`, `service_bus_topic_endpoint_id`, or `webhook_endpoint` endpoint specification. -* `header_name` - (Required) The name of the header to send on to the destination +* `header_name` - (Required) The name of the header to send on to the destination. * `type` - (Required) Either `Static` or `Dynamic` From 31bec7574e4a597c0655482ec1b15b9b8a8d3cc0 Mon Sep 17 00:00:00 2001 From: Jack Muskopf Date: Mon, 7 Mar 2022 10:04:44 -0600 Subject: [PATCH 14/21] Add period to end of description Co-authored-by: stephybun --- .../r/eventgrid_system_topic_event_subscription.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c97dd7ea966d..5b9f7575f86a 100644 --- a/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown @@ -205,7 +205,7 @@ A `delivery_property` supports the following: * `header_name` - (Required) The name of the header to send on to the destination. -* `type` - (Required) Either `Static` or `Dynamic` +* `type` - (Required) Either `Static` or `Dynamic`. * `value` - (Optional) If the `type` is `Static`, then provide the value to use From 3c42298a765885cdd6e102d5c5a599abe93d39ed Mon Sep 17 00:00:00 2001 From: Jack Muskopf Date: Mon, 7 Mar 2022 10:04:55 -0600 Subject: [PATCH 15/21] Add period to end of description Co-authored-by: stephybun --- .../r/eventgrid_system_topic_event_subscription.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5b9f7575f86a..c4e1e1693664 100644 --- a/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown @@ -207,7 +207,7 @@ A `delivery_property` supports the following: * `type` - (Required) Either `Static` or `Dynamic`. -* `value` - (Optional) If the `type` is `Static`, then provide the value to use +* `value` - (Optional) If the `type` is `Static`, then provide the value to use. * `source_field` - (Optional) If the `type` is `Dynamic`, then provide the payload field to be used as the value. Valid source fields differ by subscription type. From 6489f05e7043f1fe7db5f6967d8f1c53a6415a97 Mon Sep 17 00:00:00 2001 From: Jack Muskopf Date: Mon, 7 Mar 2022 10:05:24 -0600 Subject: [PATCH 16/21] Use ticks to indicate boolean value Co-authored-by: stephybun --- .../r/eventgrid_system_topic_event_subscription.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c4e1e1693664..ecd6ece2d9ce 100644 --- a/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_system_topic_event_subscription.html.markdown @@ -211,7 +211,7 @@ A `delivery_property` supports the following: * `source_field` - (Optional) If the `type` is `Dynamic`, then provide the payload field to be used as the value. Valid source fields differ by subscription type. -* `secret` - (Optional) True if the `value` is a secret and should be protected, otherwise false. If True, then this value won't be returned from Azure API calls +* `secret` - (Optional) Set to `true` if the `value` is a secret and should be protected, otherwise `false`. If `true` then this value won't be returned from Azure API calls. --- From c206585f03feb22c7497e241b6a1f51655f19579 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Mar 2022 16:39:46 -0600 Subject: [PATCH 17/21] terrafmt applied to internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go --- ...entgrid_system_topic_event_subscription_resource_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 9551066f12cc..9e5c3ab5d92d 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -1481,7 +1481,7 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { value = "string" secret = false } - + } `, data.RandomInteger, data.Locations.Primary, data.RandomString) } @@ -1531,7 +1531,7 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { subject_filter { subject_begins_with = "test/test" } - + delivery_property { header_name = "test-secret-1" type = "Static" @@ -1600,7 +1600,7 @@ resource "azurerm_eventgrid_system_topic_event_subscription" "test" { type = "Dynamic" source_field = "data.system" } - + delivery_property { header_name = "test-secret-1" type = "Static" From 1b8a9cd0ca662f39ecf3e613efee0d9876492c76 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Mar 2022 15:52:38 -0600 Subject: [PATCH 18/21] fix for 3.0 beta errors --- ..._topic_event_subscription_resource_test.go | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 9e5c3ab5d92d..84f1e8fea403 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -800,7 +800,7 @@ resource "azurerm_eventhub_namespace" "test" { resource "azurerm_eventhub" "test" { name = "acctesteventhub-%[1]d" - namespace_name = azurerm_eventhub_namespace.test.name + namespace_id = azurerm_eventhub_namespace.test.id resource_group_name = azurerm_resource_group.test.name partition_count = 2 message_retention = 1 @@ -847,7 +847,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_queue" "test" { name = "acctestservicebusqueue-%[1]d" resource_group_name = azurerm_resource_group.test.name - namespace_name = azurerm_servicebus_namespace.example.name + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -890,8 +890,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - resource_group_name = azurerm_resource_group.test.name - namespace_name = azurerm_servicebus_namespace.example.name + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1442,8 +1441,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - resource_group_name = azurerm_resource_group.test.name - namespace_name = azurerm_servicebus_namespace.example.name + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1506,8 +1504,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - resource_group_name = azurerm_resource_group.test.name - namespace_name = azurerm_servicebus_namespace.example.name + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1562,8 +1559,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - resource_group_name = azurerm_resource_group.test.name - namespace_name = azurerm_servicebus_namespace.example.name + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1631,8 +1627,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - resource_group_name = azurerm_resource_group.test.name - namespace_name = azurerm_servicebus_namespace.example.name + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1700,7 +1695,7 @@ resource "azurerm_eventhub_namespace" "test" { resource "azurerm_eventhub" "test" { name = "acctesteventhub-%[1]d" - namespace_name = azurerm_eventhub_namespace.test.name + namespace_id = azurerm_eventhub_namespace.test.id resource_group_name = azurerm_resource_group.test.name partition_count = 2 message_retention = 1 From a724d644f063f078f60fe8e9f9fbf028125f97af Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Mar 2022 15:55:48 -0600 Subject: [PATCH 19/21] terrafmt changes --- ...tem_topic_event_subscription_resource_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 84f1e8fea403..576996972af0 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -800,7 +800,7 @@ resource "azurerm_eventhub_namespace" "test" { resource "azurerm_eventhub" "test" { name = "acctesteventhub-%[1]d" - namespace_id = azurerm_eventhub_namespace.test.id + namespace_id = azurerm_eventhub_namespace.test.id resource_group_name = azurerm_resource_group.test.name partition_count = 2 message_retention = 1 @@ -847,7 +847,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_queue" "test" { name = "acctestservicebusqueue-%[1]d" resource_group_name = azurerm_resource_group.test.name - namespace_id = azurerm_servicebus_namespace.example.id + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -890,7 +890,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - namespace_id = azurerm_servicebus_namespace.example.id + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1441,7 +1441,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - namespace_id = azurerm_servicebus_namespace.example.id + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1504,7 +1504,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - namespace_id = azurerm_servicebus_namespace.example.id + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1559,7 +1559,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - namespace_id = azurerm_servicebus_namespace.example.id + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1627,7 +1627,7 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%[1]d" - namespace_id = azurerm_servicebus_namespace.example.id + namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } @@ -1695,7 +1695,7 @@ resource "azurerm_eventhub_namespace" "test" { resource "azurerm_eventhub" "test" { name = "acctesteventhub-%[1]d" - namespace_id = azurerm_eventhub_namespace.test.id + namespace_id = azurerm_eventhub_namespace.test.id resource_group_name = azurerm_resource_group.test.name partition_count = 2 message_retention = 1 From f0f53ecac907b6b27f1478a796c1fd09c0f44f67 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Mar 2022 16:41:12 -0600 Subject: [PATCH 20/21] rm rgname --- .../eventgrid_system_topic_event_subscription_resource_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index 576996972af0..f18b0e6d0ed3 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -846,7 +846,6 @@ resource "azurerm_servicebus_namespace" "example" { resource "azurerm_servicebus_queue" "test" { name = "acctestservicebusqueue-%[1]d" - resource_group_name = azurerm_resource_group.test.name namespace_id = azurerm_servicebus_namespace.example.id enable_partitioning = true } From bb4c30abacf471873bc1000ba03f2fdc56185929 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Mar 2022 16:43:08 -0600 Subject: [PATCH 21/21] eventhub still uses namespace_name --- ...eventgrid_system_topic_event_subscription_resource_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go index f18b0e6d0ed3..9ad600cc98e5 100644 --- a/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go +++ b/internal/services/eventgrid/eventgrid_system_topic_event_subscription_resource_test.go @@ -800,7 +800,7 @@ resource "azurerm_eventhub_namespace" "test" { resource "azurerm_eventhub" "test" { name = "acctesteventhub-%[1]d" - namespace_id = azurerm_eventhub_namespace.test.id + namespace_name = azurerm_eventhub_namespace.test.name resource_group_name = azurerm_resource_group.test.name partition_count = 2 message_retention = 1 @@ -1694,7 +1694,7 @@ resource "azurerm_eventhub_namespace" "test" { resource "azurerm_eventhub" "test" { name = "acctesteventhub-%[1]d" - namespace_id = azurerm_eventhub_namespace.test.id + namespace_name = azurerm_eventhub_namespace.test.name resource_group_name = azurerm_resource_group.test.name partition_count = 2 message_retention = 1