Terraform- Azure Event Grid Subscription with Event hub endpoint

Doing Event Grid Subscription with a EventHub endpoint I got the error like Blocks of type "eventhub_endpoint" are not expected here. Not sure what I'm missing here. Is the eventhub_endpoint is not a valid one ? How can i configure the eventhub for my event grid sub ?

Doing Event Grid Subscription with a EventHub endpoint

resource "azurerm_eventgrid_system_topic_event_subscription" "example" { name = "example-event-subscription" system_topic = azurerm_system_topic.example.name resource_group_name = azurerm_resource_group.example.name eventhub_endpoint { eventhub_endpoint_id = azurerm_eventhub.example.id } 

I got the error like

Blocks of type "eventhub_endpoint" are not expected here.

Not sure what I'm missing here. Is the eventhub_endpoint is not a valid one ? How can i configure the eventhub for my event grid sub ?

1 Answer

Regarding the issue, please update your script as

resource "azurerm_eventgrid_system_topic_event_subscription" "example" { name = "example-event-subscription" system_topic = azurerm_eventgrid_system_topic.example.name resource_group_name = azurerm_resource_group.example.name eventhub_endpoint_id = azurerm_eventhub.example.id } 

For more details, please refer to here. enter image description here

For example (I use terraform 0.15.4 on windows)

terraform { required_providers { azurerm = { source = "hashicorp/azurerm" version = "=2.46.0" } } } provider "azurerm" { subscription_id = "e5b0fcfa-e859-43f3-8d84-5e5fe29f4c68" client_id = "42e0d080-b1f3-40cf-8db6-c4c522d988c4" client_secret = "Gbx2eK64iqq_g_3NCA.ClJDfQpIjoae:" tenant_id = "e4c9ab4e-bd27-40d5-8459-230ba2a757fb" features {} } resource "azurerm_resource_group" "example" { name = "example-rg" location = "West Europe" } resource "azurerm_eventhub_namespace" "example" { name = "testhubname0123" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name sku = "Standard" capacity = 1 tags = { environment = "Production" } } resource "azurerm_eventhub" "example" { name = "testhub0123" namespace_name = azurerm_eventhub_namespace.example.name resource_group_name = azurerm_resource_group.example.name partition_count = 2 message_retention = 1 } resource "azurerm_eventgrid_system_topic" "example" { name = "example-system-topic" location = "Global" resource_group_name = azurerm_resource_group.example.name source_arm_resource_id = azurerm_resource_group.example.id topic_type = "Microsoft.Resources.ResourceGroups" } resource "azurerm_eventgrid_system_topic_event_subscription" "example" { name = "example-event-subscription" system_topic = azurerm_eventgrid_system_topic.example.name resource_group_name = azurerm_resource_group.example.name eventhub_endpoint_id = azurerm_eventhub.example.id } 

enter image description here

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobXBvYmmAeYWOrZyrqpGbvLO5jJqxrqqVYrK3sc2tZKCqmZl6tMHBrJqroaCptrC6jLCgraBdmsOmutNmn66aXZq7pbzOoqWt

 Share!