-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
IoT Hub Consumer Group creation fails if the same 'apply' step tries to create a component, which depends on it #7444
Comments
We had the same kind of issue on iothub when trying to create in the same apply 2 consumer group and 1 SAS Policy. As a workaround, we set an explicit dependency with |
@royto, thanks for forcing me into this direction! Below are simplified version of my resources (I dropped registration of other endpoints/routes to shorten the sample) What I had before (this one fails all the time): resource "azurerm_iothub" "ingestion" {
name = var.iothub_name
resource_group_name = azurerm_resource_group.rg_ingestion.name
location = azurerm_resource_group.rg_ingestion.location
sku {
name = var.iot_sku.name
capacity = var.iot_sku.capacity
}
route {
name = "defaultroute"
source = "DeviceMessages"
condition = "true"
endpoint_names = ["events"]
enabled = true
}
}
resource "azurerm_iothub_consumer_group" "normalizer" {
name = "normalizer"
iothub_name = azurerm_iothub.ingestion.name
eventhub_endpoint_name = "events"
resource_group_name = azurerm_resource_group.rg_ingestion.name
} How I changed it (this one works fine most of the time): resource "azurerm_iothub" "ingestion" {
name = var.iothub_name
resource_group_name = azurerm_resource_group.rg_ingestion.name
location = azurerm_resource_group.rg_ingestion.location
sku {
name = var.iot_sku.name
capacity = var.iot_sku.capacity
}
}
resource "azurerm_iothub_route" "default_iot_eh_route" {
resource_group_name = azurerm_resource_group.rg_ingestion.name
iothub_name = azurerm_iothub.ingestion.name
name = "defaultroute"
source = "DeviceMessages"
condition = "true"
endpoint_names = ["events"]
enabled = true
}
resource "azurerm_iothub_consumer_group" "normalizer" {
name = "normalizer"
iothub_name = azurerm_iothub.ingestion.name
eventhub_endpoint_name = "events"
resource_group_name = azurerm_resource_group.rg_ingestion.name
depends_on = [ azurerm_iothub_route.default_iot_eh_route ]
} Root causeIf the default route for I do not fully understand, how The failure happens in resourceArmIotHubConsumerGroupCreate function, which calls azure-sdk GetEventHubConsumerGroup method after creating the consumer group. WorkaroundMove default route definition out of As a hack, I added the consumer-group dependency on iot-hub-policy, which takes a while to complete. It's a kind of simulated delay, but I've just gave up to debug the issue further. |
Glad it helps 😉 |
Thanks for opening this issue. After investigated, I assume iothub seems api doesn't allow multiple operations in the same time. So I made a fix to add a lock on iothub while operating iothub consumer group. Hopes it would be helpful. Thanks. |
This has been released in version 2.23.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.23.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! |
Community Note
Description
Azure IoT Hub supports built-in event-hub endpoint, where device-telemetry messages are routed by default. Terraform supports adding Consumer Groups to this endpoint. Other parts of terraform configuration should be able to use Consumer Group resource as a reference.
We use a setup, when Azure Function reads telemetry data from IoT Hub, using a dedicated consumer group and IoT Hub policy. When this infrastructure is created the first time, terraform throws an exception like:
The problem appears if IoT Hub and Consumer Group resources are created in the same
apply
step with the dependent component.Terraform (and AzureRM Provider) Version
Affected Resource(s)
azurerm_iothub_consumer_group
Terraform Configuration Files
The entire configuration is committed to the repo: https://github.com/v1r7u/azurerm_issues/blob/master/src/iot_eventhub_listener/main.tf
Expected Behavior
Terraform is able to create in the same step:
IoT Hub
,IoT Hub Policy
,IoT Hub Consumer Group
, andAzure Function
which consumes them.Actual Behavior
Terraform properly creates
IoT Hub
andIoT Hub Policy
, fails during creatingConsumer Group
andAzure Function
, which depends on it.Steps to Reproduce
Detailed steps to reproduce and terraform configuration sample I've committed to the repo:
https://github.com/v1r7u/azurerm_issues/tree/master/src/iot_eventhub_listener
The text was updated successfully, but these errors were encountered: