From d66260cc90daea0574349d2375423e2239ac598d Mon Sep 17 00:00:00 2001 From: royto Date: Wed, 11 Nov 2020 15:10:33 +0100 Subject: [PATCH] Add Documentation --- website/docs/r/iothub.html.markdown | 27 +++- .../docs/r/iothub_enrichment.html.markdown | 117 ++++++++++++++++++ 2 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 website/docs/r/iothub_enrichment.html.markdown diff --git a/website/docs/r/iothub.html.markdown b/website/docs/r/iothub.html.markdown index 9decf6b3ab60a..6583615556d49 100644 --- a/website/docs/r/iothub.html.markdown +++ b/website/docs/r/iothub.html.markdown @@ -14,6 +14,8 @@ Manages an IotHub ~> **NOTE:** Routes can be defined either directly on the `azurerm_iothub` resource, or using the `azurerm_iothub_route` resource - but the two cannot be used together. If both are used against the same IoTHub, spurious changes will occur. +~> **NOTE:** Enrichments can be defined either directly on the `azurerm_iothub` resource, or using the `azurerm_iothub_enrichment` resource - but the two cannot be used together. If both are used against the same IoTHub, spurious changes will occur. + ~> **NOTE:** Fallback route can be defined either directly on the `azurerm_iothub` resource, or using the `azurerm_iothub_fallback_route` resource - but the two cannot be used together. If both are used against the same IoTHub, spurious changes will occur. ## Example Usage @@ -104,6 +106,12 @@ resource "azurerm_iothub" "example" { enabled = true } + enrichment { + key = "tenant" + value = "$twin.tags.Tenant" + endpoint_names = ["export", "export2"] + } + tags = { purpose = "testing" } @@ -118,7 +126,7 @@ The following arguments are supported: * `resource_group_name` - (Required) The name of the resource group under which the IotHub resource has to be created. Changing this forces a new resource to be created. -* `location` - (Required) Specifies the supported Azure location where the resource has to be createc. Changing this forces a new resource to be created. +* `location` - (Required) Specifies the supported Azure location where the resource has to be created. Changing this forces a new resource to be created. * `sku` - (Required) A `sku` block as defined below. @@ -138,7 +146,9 @@ The following arguments are supported: * `route` - (Optional) A `route` block as defined below. -* `public_network_access_enabled` - (Optional) Is the IotHub resource accessible from a public network? +* `enrichment` - (Optional) A `enrichment` block as defined below. + +* `public_network_access_enabled` - (Optional) Is the IotHub resource accessible from a public network? * `min_tls_version` - (Optional) Specifies the minimum TLS version to support for this hub. The only valid value is `1.2`. Changing this forces a new resource to be created. @@ -202,6 +212,16 @@ A `route` block supports the following: --- +An `enrichment` block supports the following: + +* `key` - (Required) The key of the enrichment. + +* `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: `$twin.tags.latitude`) + +* `endpoint_names` - (Required) The list of endpoints which will be enriched. + +--- + A `fallback_route` block supports the following: * `source` - (Optional) The source that the routing rule is to be applied to, such as `DeviceMessages`. Possible values include: `RoutingSourceInvalid`, `RoutingSourceDeviceMessages`, `RoutingSourceTwinChangeEvents`, `RoutingSourceDeviceLifecycleEvents`, `RoutingSourceDeviceJobLifecycleEvents`. @@ -230,7 +250,6 @@ A `file_upload` block supports the following: * `max_delivery_count` - (Optional) The number of times the IoT hub attempts to deliver a file upload notification message. It evaluates to 10 by default. - ## Attributes Reference The following attributes are exported: @@ -262,8 +281,6 @@ A `shared access policy` block contains the following: ## Timeouts - - The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: * `create` - (Defaults to 30 minutes) Used when creating the IotHub. diff --git a/website/docs/r/iothub_enrichment.html.markdown b/website/docs/r/iothub_enrichment.html.markdown new file mode 100644 index 0000000000000..9379ec2f4ee34 --- /dev/null +++ b/website/docs/r/iothub_enrichment.html.markdown @@ -0,0 +1,117 @@ +--- +subcategory: "Messaging" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_iothub_enrichment" +description: |- + Manages an IotHub Enrichment +--- + +# azurerm_iothub_enrichment + +Manages an IotHub Enrichment + +~> **NOTE:** Enrichment can be defined either directly on the `azurerm_iothub` resource, or using the `azurerm_iothub_enrichment` resources - but the two cannot be used together. If both are used against the same IoTHub, spurious changes will occur. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West US" +} + +resource "azurerm_storage_account" "example" { + name = "examplestorageaccount" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_storage_container" "example" { + name = "example" + storage_account_name = azurerm_storage_account.example.name + container_access_type = "private" +} + +resource "azurerm_iothub" "example" { + name = "exampleIothub" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + + sku { + name = "S1" + capacity = "1" + } + + tags = { + purpose = "testing" + } +} + +resource "azurerm_iothub_endpoint_storage_container" "example" { + resource_group_name = azurerm_resource_group.example.name + iothub_name = azurerm_iothub.example.name + name = "example" + + connection_string = azurerm_storage_account.example.primary_blob_connection_string + batch_frequency_in_seconds = 60 + max_chunk_size_in_bytes = 10485760 + container_name = azurerm_storage_container.example.name + encoding = "Avro" + file_name_format = "{iothub}/{partition}_{YYYY}_{MM}_{DD}_{HH}_{mm}" +} + +resource "azurerm_iothub_route" "example" { + resource_group_name = azurerm_resource_group.example.name + iothub_name = azurerm_iothub.example.name + name = "example" + + source = "DeviceMessages" + condition = "true" + endpoint_names = [azurerm_iothub_endpoint_storage_container.example.name] + enabled = true +} + +resource "azurerm_iothub_enrichment" "example" { + resource_group_name = azurerm_resource_group.example.name + iothub_name = azurerm_iothub.example.name + key = "example" + + value = "my value" + endpoint_names = [azurerm_iothub_endpoint_storage_container.example.name] +} +``` + +## Argument Reference + +The following arguments are supported: + +* `key` - (Required) The key of the enrichment. + +* `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: `$twin.tags.latitude`) + +* `endpoint_names` - (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](https://www.terraform.io/docs/configuration/resources.html#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 `resource id`, e.g. + +```shell +terraform import azurerm_iothub_enrichment.enrichment1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Devices/IotHubs/hub1/Enrichments/enrichment1 +```