diff --git a/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go b/azurerm/internal/services/eventgrid/eventgrid_event_subscription_resource.go index a2f764e2acdc..0348e961cebd 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 no longer has any affect and will be removed in version 3.0 of the provider.", }, "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