title: Creating an event subscription for Azure storage account in Terraform
body: <p>I am trying to create the following resources in Azure using <strong>Terraform</strong> and <strong>Terraform provider for Azure</strong>.</p>
  
  <ul>
  <li>Create a storage account for blob storage.</li>
  <li>Create an event subscription that will raise events on blob activity.</li>
  </ul>
  
  <p>When running the terraform scripts i get the following error </p>
  
  <blockquote>
    <p>Error: Error creating/updating EventGrid Event Subscription
    "evtFileReceived" (Scope
    "/subscriptions/c17cf5ee-d3d7-4f64-b863-f2a4d6948594/resourceGroups/dominos-doodle"):
    eventgrid.EventSubscriptionsClient#CreateOrUpdate: Failure sending
    request: StatusCode=400 -- Original Error: Code="InvalidRequest"
    Message="The specified topic property does not match the expected
    topic from the event subscription scope."</p>
  </blockquote>
  
  <p>How shoud i fix it ?. Google search didn't gave any results. <br></p>
  
  <p>The script that generated the error is as follows. The step that throwed the error is <code>terraform apply</code></p>
  
  <p>Obviously one way is to use the ARM templates to achieve this, but i am trying to see if it can be created using native Terraform scripts. I referred to <a href="https://www.terraform.io/docs/providers/azurerm/r/eventgrid_event_subscription.html#webhook_endpoint" rel="nofollow noreferrer">Terraform Docs</a> and created the following. </p>
  
  <pre><code>variable "inp_resource_group_name" { }
  variable "inp_geo_location" { }
  variable "inp_account_name" { }
  variable "inp_az_subscription_id" { }
  variable "inp_resource_group_id" { }
  
  resource "azurerm_storage_account" "cave" {
    name                     = var.inp_account_name
    resource_group_name      = var.inp_resource_group_name
    location                 = var.inp_geo_location
    account_tier             = "Standard"
    account_replication_type = "LRS"
    account_kind             = "StorageV2"
  }
  
  resource "azurerm_storage_container" "validName" {
    name                  = validName"
    resource_group_name   = var.inp_resource_group_name
    storage_account_name  = var.inp_account_name
    container_access_type = "blob"
  }
  
  resource "azurerm_eventgrid_event_subscription" "evtFileReceived" {
    name  = "evtFileReceived"
    scope = var.inp_resource_group_id
    topic_name="/subscriptions/${var.inp_az_subscription_id}/resourceGroups/${var.inp_resource_group_name}/providers/Microsoft.Storage/storageAccounts/{var.inp_account_name}"
    webhook_endpoint {
      url = "https://myendpoint.that.works.well.across.all.osi.layers"
    }
  }
  </code></pre>