Skip to content

azurermIothubEnrichment

Manages an IotHub Enrichment

\~> NOTE: Enrichment can be defined either directly on the azurermIothub resource, or using the azurermIothubEnrichment resources - but the two cannot be used together. If both are used against the same IoTHub, spurious changes will occur.

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 azurermStorageAccountExample = new azurerm.storageAccount.StorageAccount(
  this,
  "example_1",
  {
    account_replication_type: "LRS",
    account_tier: "Standard",
    location: azurermResourceGroupExample.location,
    name: "examplestorageaccount",
    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.*/
azurermStorageAccountExample.overrideLogicalId("example");
const azurermStorageContainerExample =
  new azurerm.storageContainer.StorageContainer(this, "example_2", {
    container_access_type: "private",
    name: "example",
    storage_account_name: azurermStorageAccountExample.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.*/
azurermStorageContainerExample.overrideLogicalId("example");
const azurermIothubExample = new azurerm.iothub.Iothub(this, "example_3", {
  location: azurermResourceGroupExample.location,
  name: "exampleIothub",
  resource_group_name: azurermResourceGroupExample.name,
  sku: [
    {
      capacity: "1",
      name: "S1",
    },
  ],
  tags: {
    purpose: "testing",
  },
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermIothubExample.overrideLogicalId("example");
const azurermIothubEndpointStorageContainerExample =
  new azurerm.iothubEndpointStorageContainer.IothubEndpointStorageContainer(
    this,
    "example_4",
    {
      batch_frequency_in_seconds: 60,
      connection_string:
        azurermStorageAccountExample.primaryBlobConnectionString,
      container_name: azurermStorageContainerExample.name,
      encoding: "Avro",
      file_name_format: "{iothub}/{partition}_{YYYY}_{MM}_{DD}_{HH}_{mm}",
      iothub_id: azurermIothubExample.id,
      max_chunk_size_in_bytes: 10485760,
      name: "example",
      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.*/
azurermIothubEndpointStorageContainerExample.overrideLogicalId("example");
const azurermIothubEnrichmentExample =
  new azurerm.iothubEnrichment.IothubEnrichment(this, "example_5", {
    endpoint_names: [azurermIothubEndpointStorageContainerExample.name],
    iothub_name: azurermIothubExample.name,
    key: "example",
    resource_group_name: azurermResourceGroupExample.name,
    value: "my value",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermIothubEnrichmentExample.overrideLogicalId("example");
const azurermIothubRouteExample = new azurerm.iothubRoute.IothubRoute(
  this,
  "example_6",
  {
    condition: "true",
    enabled: true,
    endpoint_names: [azurermIothubEndpointStorageContainerExample.name],
    iothub_name: azurermIothubExample.name,
    name: "example",
    resource_group_name: azurermResourceGroupExample.name,
    source: "DeviceMessages",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermIothubRouteExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • iothubName - (Required) The IoTHub name of the enrichment. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group under which the IoTHub resource is created. Changing this forces a new resource to be created.

  • key - (Required) The key of the enrichment. Changing this forces a new resource to be created.

  • value - (Required) The value of the enrichment. Value can be any static string, the name of the IoT hub sending the message (use $iothubname) or information from the device twin (ex: $twinTagsLatitude)

  • endpointNames - (Required) The list of endpoints which will be enriched.

Attributes Reference

The following attributes are exported:

  • id - The ID of the IoTHub Enrichment.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the IotHub Enrichment.
  • update - (Defaults to 30 minutes) Used when updating the IotHub Enrichment.
  • read - (Defaults to 5 minutes) Used when retrieving the IotHub Enrichment.
  • delete - (Defaults to 30 minutes) Used when deleting the IotHub Enrichment.

Import

IoTHub Enrichment can be imported using the resourceId, e.g.

terraform import azurerm_iothub_enrichment.enrichment1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Devices/iotHubs/hub1/enrichments/enrichment1