I am trying to automate setting up of IoT Hub. But I am not able to find any code related to creating a device in the IoT Hub. I found the below command:
resource “azurerm_iothub_device” “example” {
name = “device_name” iothub_name = azurerm_iothub.iothub12.name
}
But it does not seem to be valid.
I have installed the extensions azure IoT Hub and IoT Device Workbench.
How can I do it?
2
Answers
According to EliiseS, as of now, support for IoT Hub device creation using Terraform is not available.
A workaround I use is to use a local provisioner. I use it in my iothub resource for creation. The downside is that it only works on resource creation (or deletion) – so if devices need to be updated at a later stage without recreating the IoT hub you would need to create a new resource with said provisioner.
My provisioner:
And the create-iot-device.sh