Skip to content

azurermDigitalTwinsTimeSeriesDatabaseConnection

Manages a Digital Twins Time Series Database Connection.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermDigitalTwinsInstanceExample =
  new azurerm.digitalTwinsInstance.DigitalTwinsInstance(this, "example_1", {
    identity: [
      {
        type: "SystemAssigned",
      },
    ],
    location: azurermResourceGroupExample.location,
    name: "example-DT",
    resource_group_name: azurermResourceGroupExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermDigitalTwinsInstanceExample.overrideLogicalId("example");
const azurermEventhubNamespaceExample =
  new azurerm.eventhubNamespace.EventhubNamespace(this, "example_2", {
    location: azurermResourceGroupExample.location,
    name: "exampleEventHubNamespace",
    resource_group_name: azurermResourceGroupExample.name,
    sku: "Standard",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermEventhubNamespaceExample.overrideLogicalId("example");
const azurermKustoClusterExample = new azurerm.kustoCluster.KustoCluster(
  this,
  "example_3",
  {
    location: azurermResourceGroupExample.location,
    name: "examplekc",
    resource_group_name: azurermResourceGroupExample.name,
    sku: [
      {
        capacity: 1,
        name: "Dev(No SLA)_Standard_D11_v2",
      },
    ],
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermKustoClusterExample.overrideLogicalId("example");
const azurermKustoDatabaseExample = new azurerm.kustoDatabase.KustoDatabase(
  this,
  "example_4",
  {
    cluster_name: azurermKustoClusterExample.name,
    location: azurermResourceGroupExample.location,
    name: "example-kusto-database",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermKustoDatabaseExample.overrideLogicalId("example");
const azurermKustoDatabasePrincipalAssignmentExample =
  new azurerm.kustoDatabasePrincipalAssignment.KustoDatabasePrincipalAssignment(
    this,
    "example_5",
    {
      cluster_name: azurermKustoClusterExample.name,
      database_name: azurermKustoDatabaseExample.name,
      name: "dataadmin",
      principal_id: `\${${azurermDigitalTwinsInstanceExample.identity}.0.principal_id}`,
      principal_type: "App",
      resource_group_name: azurermResourceGroupExample.name,
      role: "Admin",
      tenant_id: `\${${azurermDigitalTwinsInstanceExample.identity}.0.tenant_id}`,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermKustoDatabasePrincipalAssignmentExample.overrideLogicalId("example");
const azurermRoleAssignmentDatabaseContributor =
  new azurerm.roleAssignment.RoleAssignment(this, "database_contributor", {
    principal_id: `\${${azurermDigitalTwinsInstanceExample.identity}.0.principal_id}`,
    role_definition_name: "Contributor",
    scope: azurermKustoDatabaseExample.id,
  });
const azurermEventhubExample = new azurerm.eventhub.Eventhub(
  this,
  "example_7",
  {
    message_retention: 7,
    name: "exampleEventHub",
    namespace_name: azurermEventhubNamespaceExample.name,
    partition_count: 2,
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermEventhubExample.overrideLogicalId("example");
const azurermEventhubConsumerGroupExample =
  new azurerm.eventhubConsumerGroup.EventhubConsumerGroup(this, "example_8", {
    eventhub_name: azurermEventhubExample.name,
    name: "example-consumergroup",
    namespace_name: azurermEventhubNamespaceExample.name,
    resource_group_name: azurermResourceGroupExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermEventhubConsumerGroupExample.overrideLogicalId("example");
const azurermRoleAssignmentEventhubDataOwner =
  new azurerm.roleAssignment.RoleAssignment(this, "eventhub_data_owner", {
    principal_id: `\${${azurermDigitalTwinsInstanceExample.identity}.0.principal_id}`,
    role_definition_name: "Azure Event Hubs Data Owner",
    scope: azurermEventhubExample.id,
  });
const azurermDigitalTwinsTimeSeriesDatabaseConnectionExample =
  new azurerm.digitalTwinsTimeSeriesDatabaseConnection.DigitalTwinsTimeSeriesDatabaseConnection(
    this,
    "example_10",
    {
      depends_on: [
        `\${${azurermRoleAssignmentDatabaseContributor.fqn}}`,
        `\${${azurermRoleAssignmentEventhubDataOwner.fqn}}`,
        `\${${azurermKustoDatabasePrincipalAssignmentExample.fqn}}`,
      ],
      digital_twins_id: azurermDigitalTwinsInstanceExample.id,
      eventhub_consumer_group_name: azurermEventhubConsumerGroupExample.name,
      eventhub_name: azurermEventhubExample.name,
      eventhub_namespace_endpoint_uri: `sb://\${${azurermEventhubNamespaceExample.name}}.servicebus.windows.net`,
      eventhub_namespace_id: azurermEventhubNamespaceExample.id,
      kusto_cluster_id: azurermKustoClusterExample.id,
      kusto_cluster_uri: azurermKustoClusterExample.uri,
      kusto_database_name: azurermKustoDatabaseExample.name,
      kusto_table_name: "exampleTable",
      name: "example-connection",
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermDigitalTwinsTimeSeriesDatabaseConnectionExample.overrideLogicalId(
  "example"
);

Arguments Reference

The following arguments are supported:

  • name - (Required) The name which should be used for this Digital Twins Time Series Database Connection. Changing this forces a new resource to be created.

  • digitalTwinsId - (Required) The ID of the Digital Twins. Changing this forces a new resource to be created.

  • eventhubName - (Required) Name of the Event Hub. Changing this forces a new resource to be created.

  • eventhubNamespaceEndpointUri - (Required) URI of the Event Hub Namespace. Changing this forces a new resource to be created.

  • eventhubNamespaceId - (Required) The ID of the Event Hub Namespace. Changing this forces a new resource to be created.

  • kustoClusterId - (Required) The ID of the Kusto Cluster. Changing this forces a new resource to be created.

  • kustoClusterUri - (Required) URI of the Kusto Cluster. Changing this forces a new resource to be created.

  • kustoDatabaseName - (Required) Name of the Kusto Database. Changing this forces a new resource to be created.


  • eventhubConsumerGroupName - (Optional) Name of the Event Hub Consumer Group. Changing this forces a new resource to be created. Defaults to $default.

  • kustoTableName - (Optional) Name of the Kusto Table. Changing this forces a new resource to be created.

Attributes Reference

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

  • id - The ID of the Digital Twins Time Series Database Connection.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the Digital Twins Time Series Database Connection.
  • read - (Defaults to 5 minutes) Used when retrieving the Digital Twins Time Series Database Connection.
  • delete - (Defaults to 30 minutes) Used when deleting the Digital Twins Time Series Database Connection.

Import

Digital Twins Time Series Database Connections can be imported using the resourceId, 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