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.
Run into the same issue, any news/ workarounds?
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
Started to develop a workaround with "local-exec" using azure cli. The following two warning came across:
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!
Great thanks @wandrew26 we will take a look into it !
@wandrew26 Use "scope" instead with the id of the eventgrid topic worked great! Thank you!
@wandrew26 can I see example of how you're running output for systemkey in your external bash script?
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?
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 ...
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!
Most helpful comment
Started to develop a workaround with "local-exec" using azure cli. The following two warning came across:
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.
With this setup i was able to create the subscription between Function App and EventGrid Topic
Hope it helps!