Azure IoT Hub DPS Shared Access Policy

This page shows how to write Terraform and Azure Resource Manager for IoT Hub DPS Shared Access Policy and write them securely.

azurerm_iothub_dps_shared_access_policy (Terraform)

The DPS Shared Access Policy in IoT Hub can be configured in Terraform with the resource name azurerm_iothub_dps_shared_access_policy. The following sections describe 3 examples of how to use the resource and its parameters.

Example Usage from GitHub

azure-iot-dps.tf#L20
resource "azurerm_iothub_dps_shared_access_policy" "raspberry_pi_temp_shared_access_policy" {
  name                = "raspberry-pi-temp-shared-access-policy"
  resource_group_name = azurerm_resource_group.azure_iot_resource_group.name
  iothub_dps_name     = azurerm_iothub_dps.raspberry_pi_temp.name
  enrollment_write    = true
  enrollment_read     = true
main.tf#L7
resource "azurerm_iothub_dps_shared_access_policy" "this" {
  enrollment_read     = var.enrollment_read
  enrollment_write    = var.enrollment_write
  iothub_dps_name     = var.iothub_dps_name
  name                = var.name
  registration_read   = var.registration_read
main.tf#L7
resource "azurerm_iothub_dps_shared_access_policy" "this" {
  enrollment_read     = var.enrollment_read
  enrollment_write    = var.enrollment_write
  iothub_dps_name     = var.iothub_dps_name
  name                = var.name
  registration_read   = var.registration_read

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages an IotHub Device Provisioning Service Shared Access Policy

Microsoft.Devices/provisioningServices (Azure Resource Manager)

The provisioningServices in Microsoft.Devices can be configured in Azure Resource Manager with the resource name Microsoft.Devices/provisioningServices. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

template.json#L13
            "type": "Microsoft.Devices/provisioningServices",
            "apiVersion": "2020-03-01",
            "name": "[parameters('provisioningServices_P4_DPS_name')]",
            "location": "westeurope",
            "sku": {
                "name": "S1",
Microsoft.Devices.tests.json#L8
          "type": "Microsoft.Devices/provisioningServices",
          "apiVersion": "2017-11-15",
          "location": "West US",
          "sku": {
            "name": "S1",
            "tier": "standard",
Microsoft.Devices.tests.json#L8
          "type": "Microsoft.Devices/provisioningServices",
          "apiVersion": "2017-08-21-preview",
          "location": "West US",
          "sku": {
            "name": "S1",
            "tier": "standard",
dps.json#L9
            "type": "Microsoft.Devices/provisioningServices",
            "apiVersion": "2020-01-01",
            "name": "{0}",
            "location": "{1}",
            "sku": {{
                "name": "S1",
dps-template.json#L21
            "type": "Microsoft.Devices/provisioningServices",
            "apiVersion": "2020-01-01",
            "name": "[parameters('dpsName')]",
            "location": "[parameters('location')]",
            "sku": "[parameters('sku')]",
            "properties": {
test-list-expected.json#L5
    "type": "Microsoft.Devices/provisioningServices"
  }
]

Frequently asked questions

What is Azure IoT Hub DPS Shared Access Policy?

Azure IoT Hub DPS Shared Access Policy is a resource for IoT Hub of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure IoT Hub DPS Shared Access Policy?

For Terraform, the LucasBurgessDev/PortfolioAWSTerraform, kevinhead/azurerm and niveklabs/azurerm source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the Skarlyne/iotamazonia, Azure/azure-resource-manager-schemas and Azure/azure-resource-manager-schemas source code examples are useful. See the Azure Resource Manager Example section for further details.