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.61k stars 4.65k forks source link

IoT hub endpoint created assuming same resource group #3295

Closed ukphillips closed 4 years ago

ukphillips commented 5 years ago

Community Note

Terraform (and AzureRM Provider) Version

Terraform v0.11.13

Affected Resource(s)

IoT Hub

Terraform Configuration Files

resource "azurerm_iothub" "module" {
  name                = "${var.hubname}-iothub"
  resource_group_name = "${var.resource_group_name}"
  location            = "${var.location}"

  sku {
    name     = "${var.iothub_sku_name}"
    tier     = "${var.iothub_sku_tier}"
    capacity = "${var.iothub_sku_capacity}"
  }

  endpoint {
    type              = "AzureIotHub.ServiceBusQueue"
    connection_string = "${var.sb-queue-endpoint-connection-string}"
    name              = "myevent-queue"
  }

  route {
    name           = "myevent"
    source         = "DeviceMessages"
    condition      = "$body.eventType = 'myevent'"
    endpoint_names = ["myevent-queue"]
    enabled        = true
  }
}

Created successfully

Panic Output

N/A

Expected Behavior

Custom endpoint should be created on IoT hub

Actual Behavior

Custom endpoint appears created, but when you drill into it, there is a not found message. Upon drilling into the resources in the resource explorer:

image

My test12 queue was manually created in the portal, and is correct, but the one above it (created by TF) is created with the assumption that the servicebus will reside in the same resource group as the parent (which is the IoT hub), this is not correct and is failing to connect the resourced together properly.

I would expect there to be an optional override to specify a different resourcegrouo/subscriptionid for the queue. This also seems to be an issue with other endpoint resources as well.

Steps to Reproduce

  1. Create a servicebus queue
  2. Reference sb queue in an IoT endpoint

Important Factoids

N/A

References

neil-yechenwei commented 4 years ago

Thanks for opening this issue. Seems currently terraform would use the resource group where iothub exists as the resource group of endpoint by default. So I made a fix to allow to specify the endpoint resource group. Hopes it would be helpful. Thanks.

ghost commented 4 years ago

This has been released in version 2.34.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.34.0"
}
# ... other configuration ...
ghost commented 4 years 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 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 πŸ‘‰ hashibot-feedback@hashicorp.com. Thanks!