From c852b0e456d8a7230a81a52dfdee2b0e74c7eec0 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Thu, 23 Jul 2020 18:03:24 +0800 Subject: [PATCH 1/2] Deprecate topic_name for azurerm_eventgrid_event_subscription --- .../eventgrid_event_subscription_resource.go | 11 ++-- examples/eventgrid/event-subscription/main.tf | 59 +++++++++++++++++++ .../eventgrid/event-subscription/variables.tf | 7 +++ ...eventgrid_event_subscription.html.markdown | 2 +- 4 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 examples/eventgrid/event-subscription/main.tf create mode 100644 examples/eventgrid/event-subscription/variables.tf diff --git a/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go b/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go index a2f764e2acdc..61151d6edc1c 100644 --- a/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go +++ b/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go @@ -87,9 +87,10 @@ func resourceArmEventGridEventSubscription() *schema.Resource { }, "topic_name": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + Deprecated: "This field has been updated to readonly field since Apr 25, 2019. So remove this unnecessary field.", }, "azure_function_endpoint": { @@ -673,10 +674,6 @@ func resourceArmEventGridEventSubscriptionRead(d *schema.ResourceData, meta inte d.Set("event_delivery_schema", string(props.EventDeliverySchema)) - if props.Topic != nil && *props.Topic != "" { - d.Set("topic_name", props.Topic) - } - if azureFunctionEndpoint, ok := props.Destination.AsAzureFunctionEventSubscriptionDestination(); ok { if err := d.Set("azure_function_endpoint", flattenEventGridEventSubscriptionAzureFunctionEndpoint(azureFunctionEndpoint)); err != nil { return fmt.Errorf("Error setting `%q` for EventGrid Event Subscription %q (Scope %q): %s", "azure_function_endpoint", id.Name, id.Scope, err) diff --git a/examples/eventgrid/event-subscription/main.tf b/examples/eventgrid/event-subscription/main.tf new file mode 100644 index 000000000000..da8341dfd2fe --- /dev/null +++ b/examples/eventgrid/event-subscription/main.tf @@ -0,0 +1,59 @@ +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "example" { + name = "${var.prefix}-resources" + location = var.location +} + +resource "azurerm_storage_account" "example" { + name = "${var.prefix}sa" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_storage_queue" "example" { + name = "${var.prefix}-sq" + storage_account_name = azurerm_storage_account.example.name +} + +resource "azurerm_storage_container" "example" { + name = "vhds" + storage_account_name = azurerm_storage_account.example.name + container_access_type = "private" +} + +resource "azurerm_storage_blob" "example" { + name = "herpderp1.vhd" + + storage_account_name = azurerm_storage_account.example.name + storage_container_name = azurerm_storage_container.example.name + + type = "Page" + size = 5120 +} + +resource "azurerm_eventgrid_event_subscription" "example" { + name = "${var.prefix}-eventsubs" + scope = azurerm_resource_group.example.id + + storage_queue_endpoint { + storage_account_id = azurerm_storage_account.example.id + queue_name = azurerm_storage_queue.example.name + } + + storage_blob_dead_letter_destination { + storage_account_id = azurerm_storage_account.example.id + storage_blob_container_name = azurerm_storage_container.example.name + } + + retry_policy { + event_time_to_live = 11 + max_delivery_attempts = 11 + } + + labels = ["test", "test1", "test2"] +} diff --git a/examples/eventgrid/event-subscription/variables.tf b/examples/eventgrid/event-subscription/variables.tf new file mode 100644 index 000000000000..f8b75a591141 --- /dev/null +++ b/examples/eventgrid/event-subscription/variables.tf @@ -0,0 +1,7 @@ +variable "prefix" { + description = "The Prefix used for all resources in this example" +} + +variable "location" { + description = "The Azure Region in which all resources in this example should be created." +} diff --git a/website/docs/r/eventgrid_event_subscription.html.markdown b/website/docs/r/eventgrid_event_subscription.html.markdown index c32e799706d2..43e60e262096 100644 --- a/website/docs/r/eventgrid_event_subscription.html.markdown +++ b/website/docs/r/eventgrid_event_subscription.html.markdown @@ -198,7 +198,7 @@ The following attributes are exported: * `id` - The ID of the EventGrid Event Subscription. -* `topic_name` - (Optional) Specifies the name of the topic to associate with the event subscription. +* `topic_name` - (Optional/ **Deprecated) Specifies the name of the topic to associate with the event subscription. ## Timeouts From 8983e275a42b4bbd0ea04f8d98afb17c64f9a808 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 24 Jul 2020 08:56:23 +0800 Subject: [PATCH 2/2] Update code --- .../services/eventgrid/eventgrid_event_subscription_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go b/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go index 61151d6edc1c..0348e961cebd 100644 --- a/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go +++ b/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go @@ -90,7 +90,7 @@ func resourceArmEventGridEventSubscription() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - Deprecated: "This field has been updated to readonly field since Apr 25, 2019. So remove this unnecessary field.", + Deprecated: "This field has been updated to readonly field since Apr 25, 2019 so no longer has any affect and will be removed in version 3.0 of the provider.", }, "azure_function_endpoint": {