hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.62k stars 4.66k forks source link

Iot Hub Routes Sources not working as expected #12892

Closed mgardi85 closed 1 year ago

mgardi85 commented 3 years ago

Community Note

Description

We are using IOT HUB and the below is the way we are creating it We are facing issue in the creating routes from terraform script

Terraform version 1.0.2 Azure Provider: 2.69.0. ` resource "azurerm_resource_group" "example" { name = "example-resources-3213" location = "West Europe" }

resource "azurerm_iothub" "iot-hub" { name = "myHub" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location

sku { name = "S1" capacity = "1" } fallback_route { source = "DeviceMessages" endpoint_names = ["events"] enabled = true }

route { name = "DeviceUpdate.DigitalTwinChanges" source = "DigitalTwinChangeEvents" condition = "true" endpoint_names = ["events"] enabled = true } dependson =[ azurerm_resource_group.example ] } `

The validate command fails with message that the route source value is invalid and needs be to one of 4-5 given values.

Error: expected route.0.source to be one of [DeviceConnectionStateEvents DeviceJobLifecycleEvents DeviceLifecycleEvents DeviceMessages Invalid TwinChangeEvents], got DigitalTwinChangeEvents.

I am able to create the same route when done from Azure Portal / Az Powershell module. The possible values available in Azure Portal are as below

Referring to the documentation at [Azure RM documentation] https://registry.terraform.io/providers/hashicorp/azurerm/2.69.0/docs/resources/iothub) the possible values are listed as below

From the first look it seems there is a mismatch in sources. Is there any additional information available for mapping of route source values from tf azure provider to the ones used in azure.

mgardi85 commented 3 years ago

Is this a confirmed bug ? If so any work arounds available for get this working.

catriona-m commented 2 years ago

Hi @mgardi85 thanks for opening this. I tried to add this source as an option but unfortunately it seems it is not currently supported in the api. See: https://docs.microsoft.com/en-us/rest/api/iothub/iot-hub-resource/create-or-update#routingsource

stawii commented 1 year ago

It's Azure Portal / Docs naming issue. For example try creating "Device Telemetry Messages" in Portal, it will display as "DeviceMessages" later on via API and EVEN IN PORTAL route summary, but.. when you try to edit route, the drop-down will still show "Device Telemetry Messages" ;)

<insert same same, but different meme>

catriona-m commented 1 year ago

Sounds like this issue has been resolved and this can be closed now. Thanks!

github-actions[bot] commented 6 months ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.