Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventGrid Subscriptions resource invalid topic name error #3305

Closed
jamesdj1991 opened this issue Apr 24, 2019 · 9 comments · Fixed by #7871
Closed

EventGrid Subscriptions resource invalid topic name error #3305

jamesdj1991 opened this issue Apr 24, 2019 · 9 comments · Fixed by #7871

Comments

@jamesdj1991
Copy link

Hello,

When using the new azurerm_eventgrid_event_subscription resource manager to associate the new subscription resource to the topic, it throws an error as below:

* azurerm_eventgrid_event_subscription.sub: Error creating/updating EventGrid Event Subscription "sub" (Scope "/subscriptions/xxx-xxx-xxx-xxx-xxx/resourceGroups/sub-rg"): eventgrid.EventSubscriptionsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidRequest" Message="Invalid topic name."

Code being applied is below:

resource "azurerm_eventgrid_topic" "topic" {
name = "${var.short_location[0]}${var.environment__name}topic"
location = "${var.location[0]}"
resource_group_name = "${azurerm_resource_group.rg.*.name[0]}"
tags = "${local.default_tags}"

resource "azurerm_eventgrid_event_subscription" "sub" {
name = "${var.short_location[0]}${var.environment__name}-sub"
scope = "${azurerm_resource_group.rg.*.id[0]}"
event_delivery_schema = "EventGridSchema"
topic_name = "${azurerm_eventgrid_topic.topic.name}"
webhook_endpoint {
url = "blank"
}
}

I have tried replacing the topic_name = "${azurerm_eventgrid_topic.topic.name}" with topic_name = "${azurerm_eventgrid_topic.topic.id}" to try using the id of the resource instead. I have also attempted hard coding the topic name, to associate the subscription to the topic but it keeps showing the same error.

Any help would be much appreciated.

Thanks.

@wandrew26
Copy link

Run into the same issue, any news/ workarounds?

@jamesdj1991
Copy link
Author

Hi @wandrew26, no fix for this as far as we know - we ended up moving away from event grid for now as the solution changed.

we did have a look at passing an arm template in to do it but decided against it:
https://docs.microsoft.com/en-us/azure/templates/microsoft.eventgrid/2019-01-01/eventsubscriptions

@wandrew26
Copy link

wandrew26 commented Jun 14, 2019

Started to develop a workaround with "local-exec" using azure cli. The following two warning came across:

  • "Argument 'resource_group_name' has been deprecated and will be removed in version '2.1.0'. Use '--source-resource-id' instead."
  • "Argument 'topic_name' has been deprecated and will be removed in version '2.1.0'. Use '--source-resource-id' instead."

Realized that the resource group in this case is an art from a topic type to subscribe and not a reference where to create the subscription resource.
It seems that "topic_name" and "resource_group_name" are deprecated parameters. Use "scope" instead with the id of the eventgrid topic.

resource "azurerm_eventgrid_event_subscription" "this" {
  name       = "${var.name}"
  scope      = "${azurerm_eventgrid_topic.this.id}"

  webhook_endpoint {
    url = "https://${var.functionapp_name}.azurewebsites.net/runtime/webhooks/eventgrid?functionName=${var.function_name}&code=${data.external.script.result["systemkey"]}"
  }
}

With this setup i was able to create the subscription between Function App and EventGrid Topic

Hope it helps!

@jamesdj1991
Copy link
Author

Great thanks @wandrew26 we will take a look into it !

@chrisatrotter
Copy link

@wandrew26 Use "scope" instead with the id of the eventgrid topic worked great! Thank you!

@SteveDevOps
Copy link
Contributor

@wandrew26 can I see example of how you're running output for systemkey in your external bash script?

@markti
Copy link
Contributor

markti commented Nov 9, 2019

Started to develop a workaround with "local-exec" using azure cli. The following two warning came across:

  • "Argument 'resource_group_name' has been deprecated and will be removed in version '2.1.0'. Use '--source-resource-id' instead."
  • "Argument 'topic_name' has been deprecated and will be removed in version '2.1.0'. Use '--source-resource-id' instead."

Realized that the resource group in this case is an art from a topic type to subscribe and not a reference where to create the subscription resource.
It seems that "topic_name" and "resource_group_name" are deprecated parameters. Use "scope" instead with the id of the eventgrid topic.

resource "azurerm_eventgrid_event_subscription" "this" {
  name       = "${var.name}"
  scope      = "${azurerm_eventgrid_topic.this.id}"

  webhook_endpoint {
    url = "https://${var.functionapp_name}.azurewebsites.net/runtime/webhooks/eventgrid?functionName=${var.function_name}&code=${data.external.script.result["systemkey"]}"
  }
}

With this setup i was able to create the subscription between Function App and EventGrid Topic

Hope it helps!

Do you have the example posted somewhere?

@katbyte katbyte added this to the v2.21.0 milestone Jul 24, 2020
katbyte pushed a commit that referenced this issue Jul 24, 2020
fixes #3305

According by the [PR](Azure/azure-sdk-for-go@119eb84), topic_name has been changed to readonly field. So I remove this unnecessary field.

--- PASS: TestAccAzureRMEventGridEventSubscription_advancedFilter (307.33s)
--- PASS: TestAccAzureRMEventGridEventSubscription_filter (372.90s)
--- PASS: TestAccAzureRMEventGridEventSubscription_requiresImport (383.96s)
--- PASS: TestAccAzureRMEventGridEventSubscription_basic (401.60s)
--- PASS: TestAccAzureRMEventGridEventSubscription_serviceBusQueueID (430.50s)
--- PASS: TestAccAzureRMEventGridEventSubscription_serviceBusTopicID (522.11s)
--- PASS: TestAccAzureRMEventGridEventSubscription_eventHubID (531.38s)
--- PASS: TestAccAzureRMEventGridEventSubscription_update (647.02s)
PASS
@ghost
Copy link

ghost commented Jul 31, 2020

This has been released in version 2.21.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.21.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Aug 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants