azurerm_digital_twins_time_series_database_connection

Manages a Digital Twins Time Series Database Connection.

Example Usage

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_digital_twins_instance" "example" {
  name                = "example-DT"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location

  identity {
    type = "SystemAssigned"
  }
}

resource "azurerm_eventhub_namespace" "example" {
  name                = "exampleEventHubNamespace"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  sku                 = "Standard"
}

resource "azurerm_eventhub" "example" {
  name                = "exampleEventHub"
  namespace_name      = azurerm_eventhub_namespace.example.name
  resource_group_name = azurerm_resource_group.example.name
  partition_count     = 2
  message_retention   = 7
}

resource "azurerm_eventhub_consumer_group" "example" {
  name                = "example-consumergroup"
  namespace_name      = azurerm_eventhub_namespace.example.name
  eventhub_name       = azurerm_eventhub.example.name
  resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_kusto_cluster" "example" {
  name                = "examplekc"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  sku {
    name     = "Dev(No SLA)_Standard_D11_v2"
    capacity = 1
  }
}

resource "azurerm_kusto_database" "example" {
  name                = "example-kusto-database"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  cluster_name        = azurerm_kusto_cluster.example.name
}

resource "azurerm_role_assignment" "database_contributor" {
  scope                = azurerm_kusto_database.example.id
  principal_id         = azurerm_digital_twins_instance.example.identity[0].principal_id
  role_definition_name = "Contributor"
}

resource "azurerm_role_assignment" "eventhub_data_owner" {
  scope                = azurerm_eventhub.example.id
  principal_id         = azurerm_digital_twins_instance.example.identity[0].principal_id
  role_definition_name = "Azure Event Hubs Data Owner"
}

resource "azurerm_kusto_database_principal_assignment" "example" {
  name                = "dataadmin"
  resource_group_name = azurerm_resource_group.example.name
  cluster_name        = azurerm_kusto_cluster.example.name
  database_name       = azurerm_kusto_database.example.name

  tenant_id      = azurerm_digital_twins_instance.example.identity[0].tenant_id
  principal_id   = azurerm_digital_twins_instance.example.identity[0].principal_id
  principal_type = "App"
  role           = "Admin"
}

resource "azurerm_digital_twins_time_series_database_connection" "example" {
  name                            = "example-connection"
  digital_twins_id                = azurerm_digital_twins_instance.example.id
  eventhub_name                   = azurerm_eventhub.example.name
  eventhub_namespace_id           = azurerm_eventhub_namespace.example.id
  eventhub_namespace_endpoint_uri = "sb://${azurerm_eventhub_namespace.example.name}.servicebus.windows.net"
  eventhub_consumer_group_name    = azurerm_eventhub_consumer_group.example.name
  kusto_cluster_id                = azurerm_kusto_cluster.example.id
  kusto_cluster_uri               = azurerm_kusto_cluster.example.uri
  kusto_database_name             = azurerm_kusto_database.example.name
  kusto_table_name                = "exampleTable"

  depends_on = [
    azurerm_role_assignment.database_contributor,
    azurerm_role_assignment.eventhub_data_owner,
    azurerm_kusto_database_principal_assignment.example
  ]
}

Arguments Reference

The following arguments are supported:


Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Digital Twins Time Series Database Connections can be imported using the resource id, e.g.

terraform import azurerm_digital_twins_time_series_database_connection.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DigitalTwins/digitalTwinsInstances/dt1/timeSeriesDatabaseConnections/connection1