SharedAccessPolicy

Manages an IotHub Shared Access Policy

Example Usage

using System.Collections.Generic;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
    {
        Location = "West Europe",
    });

    var exampleIoTHub = new Azure.Iot.IoTHub("exampleIoTHub", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        Location = exampleResourceGroup.Location,
        Sku = new Azure.Iot.Inputs.IoTHubSkuArgs
        {
            Name = "S1",
            Capacity = 1,
        },
    });

    var exampleSharedAccessPolicy = new Azure.Iot.SharedAccessPolicy("exampleSharedAccessPolicy", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        IothubName = exampleIoTHub.Name,
        RegistryRead = true,
        RegistryWrite = true,
    });

});
package main

import (
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/iot"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
			Location: pulumi.String("West Europe"),
		})
		if err != nil {
			return err
		}
		exampleIoTHub, err := iot.NewIoTHub(ctx, "exampleIoTHub", &iot.IoTHubArgs{
			ResourceGroupName: exampleResourceGroup.Name,
			Location:          exampleResourceGroup.Location,
			Sku: &iot.IoTHubSkuArgs{
				Name:     pulumi.String("S1"),
				Capacity: pulumi.Int(1),
			},
		})
		if err != nil {
			return err
		}
		_, err = iot.NewSharedAccessPolicy(ctx, "exampleSharedAccessPolicy", &iot.SharedAccessPolicyArgs{
			ResourceGroupName: exampleResourceGroup.Name,
			IothubName:        exampleIoTHub.Name,
			RegistryRead:      pulumi.Bool(true),
			RegistryWrite:     pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.iot.IoTHub;
import com.pulumi.azure.iot.IoTHubArgs;
import com.pulumi.azure.iot.inputs.IoTHubSkuArgs;
import com.pulumi.azure.iot.SharedAccessPolicy;
import com.pulumi.azure.iot.SharedAccessPolicyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()        
            .location("West Europe")
            .build());

        var exampleIoTHub = new IoTHub("exampleIoTHub", IoTHubArgs.builder()        
            .resourceGroupName(exampleResourceGroup.name())
            .location(exampleResourceGroup.location())
            .sku(IoTHubSkuArgs.builder()
                .name("S1")
                .capacity("1")
                .build())
            .build());

        var exampleSharedAccessPolicy = new SharedAccessPolicy("exampleSharedAccessPolicy", SharedAccessPolicyArgs.builder()        
            .resourceGroupName(exampleResourceGroup.name())
            .iothubName(exampleIoTHub.name())
            .registryRead(true)
            .registryWrite(true)
            .build());

    }
}
import pulumi
import pulumi_azure as azure

example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_io_t_hub = azure.iot.IoTHub("exampleIoTHub",
    resource_group_name=example_resource_group.name,
    location=example_resource_group.location,
    sku=azure.iot.IoTHubSkuArgs(
        name="S1",
        capacity=1,
    ))
example_shared_access_policy = azure.iot.SharedAccessPolicy("exampleSharedAccessPolicy",
    resource_group_name=example_resource_group.name,
    iothub_name=example_io_t_hub.name,
    registry_read=True,
    registry_write=True)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleIoTHub = new azure.iot.IoTHub("exampleIoTHub", {
    resourceGroupName: exampleResourceGroup.name,
    location: exampleResourceGroup.location,
    sku: {
        name: "S1",
        capacity: 1,
    },
});
const exampleSharedAccessPolicy = new azure.iot.SharedAccessPolicy("exampleSharedAccessPolicy", {
    resourceGroupName: exampleResourceGroup.name,
    iothubName: exampleIoTHub.name,
    registryRead: true,
    registryWrite: true,
});
resources:
  exampleResourceGroup:
    type: azure:core:ResourceGroup
    properties:
      location: West Europe
  exampleIoTHub:
    type: azure:iot:IoTHub
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      location: ${exampleResourceGroup.location}
      sku:
        name: S1
        capacity: 1
  exampleSharedAccessPolicy:
    type: azure:iot:SharedAccessPolicy
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      iothubName: ${exampleIoTHub.name}
      registryRead: true
      registryWrite: true

Create SharedAccessPolicy Resource

new SharedAccessPolicy(name: string, args: SharedAccessPolicyArgs, opts?: CustomResourceOptions);
@overload
def SharedAccessPolicy(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       device_connect: Optional[bool] = None,
                       iothub_name: Optional[str] = None,
                       name: Optional[str] = None,
                       registry_read: Optional[bool] = None,
                       registry_write: Optional[bool] = None,
                       resource_group_name: Optional[str] = None,
                       service_connect: Optional[bool] = None)
@overload
def SharedAccessPolicy(resource_name: str,
                       args: SharedAccessPolicyArgs,
                       opts: Optional[ResourceOptions] = None)
func NewSharedAccessPolicy(ctx *Context, name string, args SharedAccessPolicyArgs, opts ...ResourceOption) (*SharedAccessPolicy, error)
public SharedAccessPolicy(string name, SharedAccessPolicyArgs args, CustomResourceOptions? opts = null)
public SharedAccessPolicy(String name, SharedAccessPolicyArgs args)
public SharedAccessPolicy(String name, SharedAccessPolicyArgs args, CustomResourceOptions options)
type: azure:iot:SharedAccessPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args SharedAccessPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args SharedAccessPolicyArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args SharedAccessPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args SharedAccessPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args SharedAccessPolicyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

SharedAccessPolicy Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The SharedAccessPolicy resource accepts the following input properties:

IothubName string

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

DeviceConnect bool

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

Name string

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

RegistryRead bool

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

RegistryWrite bool

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

ServiceConnect bool

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

IothubName string

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

DeviceConnect bool

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

Name string

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

RegistryRead bool

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

RegistryWrite bool

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

ServiceConnect bool

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

iothubName String

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

resourceGroupName String

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

deviceConnect Boolean

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

name String

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

registryRead Boolean

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

registryWrite Boolean

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

serviceConnect Boolean

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

iothubName string

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

resourceGroupName string

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

deviceConnect boolean

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

name string

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

registryRead boolean

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

registryWrite boolean

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

serviceConnect boolean

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

iothub_name str

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

resource_group_name str

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

device_connect bool

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

name str

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

registry_read bool

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

registry_write bool

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

service_connect bool

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

iothubName String

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

resourceGroupName String

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

deviceConnect Boolean

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

name String

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

registryRead Boolean

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

registryWrite Boolean

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

serviceConnect Boolean

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

Outputs

All input properties are implicitly available as output properties. Additionally, the SharedAccessPolicy resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

PrimaryConnectionString string

The primary connection string of the Shared Access Policy.

PrimaryKey string

The primary key used to create the authentication token.

SecondaryConnectionString string

The secondary connection string of the Shared Access Policy.

SecondaryKey string

The secondary key used to create the authentication token.

Id string

The provider-assigned unique ID for this managed resource.

PrimaryConnectionString string

The primary connection string of the Shared Access Policy.

PrimaryKey string

The primary key used to create the authentication token.

SecondaryConnectionString string

The secondary connection string of the Shared Access Policy.

SecondaryKey string

The secondary key used to create the authentication token.

id String

The provider-assigned unique ID for this managed resource.

primaryConnectionString String

The primary connection string of the Shared Access Policy.

primaryKey String

The primary key used to create the authentication token.

secondaryConnectionString String

The secondary connection string of the Shared Access Policy.

secondaryKey String

The secondary key used to create the authentication token.

id string

The provider-assigned unique ID for this managed resource.

primaryConnectionString string

The primary connection string of the Shared Access Policy.

primaryKey string

The primary key used to create the authentication token.

secondaryConnectionString string

The secondary connection string of the Shared Access Policy.

secondaryKey string

The secondary key used to create the authentication token.

id str

The provider-assigned unique ID for this managed resource.

primary_connection_string str

The primary connection string of the Shared Access Policy.

primary_key str

The primary key used to create the authentication token.

secondary_connection_string str

The secondary connection string of the Shared Access Policy.

secondary_key str

The secondary key used to create the authentication token.

id String

The provider-assigned unique ID for this managed resource.

primaryConnectionString String

The primary connection string of the Shared Access Policy.

primaryKey String

The primary key used to create the authentication token.

secondaryConnectionString String

The secondary connection string of the Shared Access Policy.

secondaryKey String

The secondary key used to create the authentication token.

Look up Existing SharedAccessPolicy Resource

Get an existing SharedAccessPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: SharedAccessPolicyState, opts?: CustomResourceOptions): SharedAccessPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        device_connect: Optional[bool] = None,
        iothub_name: Optional[str] = None,
        name: Optional[str] = None,
        primary_connection_string: Optional[str] = None,
        primary_key: Optional[str] = None,
        registry_read: Optional[bool] = None,
        registry_write: Optional[bool] = None,
        resource_group_name: Optional[str] = None,
        secondary_connection_string: Optional[str] = None,
        secondary_key: Optional[str] = None,
        service_connect: Optional[bool] = None) -> SharedAccessPolicy
func GetSharedAccessPolicy(ctx *Context, name string, id IDInput, state *SharedAccessPolicyState, opts ...ResourceOption) (*SharedAccessPolicy, error)
public static SharedAccessPolicy Get(string name, Input<string> id, SharedAccessPolicyState? state, CustomResourceOptions? opts = null)
public static SharedAccessPolicy get(String name, Output<String> id, SharedAccessPolicyState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
DeviceConnect bool

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

IothubName string

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

Name string

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

PrimaryConnectionString string

The primary connection string of the Shared Access Policy.

PrimaryKey string

The primary key used to create the authentication token.

RegistryRead bool

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

RegistryWrite bool

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

ResourceGroupName string

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

SecondaryConnectionString string

The secondary connection string of the Shared Access Policy.

SecondaryKey string

The secondary key used to create the authentication token.

ServiceConnect bool

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

DeviceConnect bool

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

IothubName string

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

Name string

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

PrimaryConnectionString string

The primary connection string of the Shared Access Policy.

PrimaryKey string

The primary key used to create the authentication token.

RegistryRead bool

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

RegistryWrite bool

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

ResourceGroupName string

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

SecondaryConnectionString string

The secondary connection string of the Shared Access Policy.

SecondaryKey string

The secondary key used to create the authentication token.

ServiceConnect bool

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

deviceConnect Boolean

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

iothubName String

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

name String

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

primaryConnectionString String

The primary connection string of the Shared Access Policy.

primaryKey String

The primary key used to create the authentication token.

registryRead Boolean

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

registryWrite Boolean

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

resourceGroupName String

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

secondaryConnectionString String

The secondary connection string of the Shared Access Policy.

secondaryKey String

The secondary key used to create the authentication token.

serviceConnect Boolean

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

deviceConnect boolean

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

iothubName string

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

name string

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

primaryConnectionString string

The primary connection string of the Shared Access Policy.

primaryKey string

The primary key used to create the authentication token.

registryRead boolean

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

registryWrite boolean

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

resourceGroupName string

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

secondaryConnectionString string

The secondary connection string of the Shared Access Policy.

secondaryKey string

The secondary key used to create the authentication token.

serviceConnect boolean

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

device_connect bool

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

iothub_name str

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

name str

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

primary_connection_string str

The primary connection string of the Shared Access Policy.

primary_key str

The primary key used to create the authentication token.

registry_read bool

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

registry_write bool

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

resource_group_name str

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

secondary_connection_string str

The secondary connection string of the Shared Access Policy.

secondary_key str

The secondary key used to create the authentication token.

service_connect bool

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

deviceConnect Boolean

Adds DeviceConnect permission to this Shared Access Account. It allows sending and receiving on the device-side endpoints.

iothubName String

The name of the IoTHub to which this Shared Access Policy belongs. Changing this forces a new resource to be created.

name String

Specifies the name of the IotHub Shared Access Policy resource. Changing this forces a new resource to be created.

primaryConnectionString String

The primary connection string of the Shared Access Policy.

primaryKey String

The primary key used to create the authentication token.

registryRead Boolean

Adds RegistryRead permission to this Shared Access Account. It allows read access to the identity registry.

registryWrite Boolean

Adds RegistryWrite permission to this Shared Access Account. It allows write access to the identity registry.

resourceGroupName String

The name of the resource group under which the IotHub Shared Access Policy resource has to be created. Changing this forces a new resource to be created.

secondaryConnectionString String

The secondary connection string of the Shared Access Policy.

secondaryKey String

The secondary key used to create the authentication token.

serviceConnect Boolean

Adds ServiceConnect permission to this Shared Access Account. It allows sending and receiving on the cloud-side endpoints.

Import

IoTHub Shared Access Policies can be imported using the resource id, e.g.

 $ pulumi import azure:iot/sharedAccessPolicy:SharedAccessPolicy shared_access_policy1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Devices/IotHubs/hub1/IotHubKeys/shared_access_policy1

Package Details

Repository
https://github.com/pulumi/pulumi-azure
License
Apache-2.0
Notes

This Pulumi package is based on the azurerm Terraform Provider.