1. Packages
  2. Azure Classic
  3. API Docs
  4. iot
  5. getSharedAccessPolicy

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

azure.iot.getSharedAccessPolicy

Explore with Pulumi AI

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

Use this data source to access information about an existing IotHub Shared Access Policy

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const example = azure.iot.getSharedAccessPolicy({
    name: "example",
    resourceGroupName: exampleAzurermResourceGroup.name,
    iothubName: exampleAzurermIothub.name,
});
Copy
import pulumi
import pulumi_azure as azure

example = azure.iot.get_shared_access_policy(name="example",
    resource_group_name=example_azurerm_resource_group["name"],
    iothub_name=example_azurerm_iothub["name"])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := iot.LookupSharedAccessPolicy(ctx, &iot.LookupSharedAccessPolicyArgs{
			Name:              "example",
			ResourceGroupName: exampleAzurermResourceGroup.Name,
			IothubName:        exampleAzurermIothub.Name,
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var example = Azure.Iot.GetSharedAccessPolicy.Invoke(new()
    {
        Name = "example",
        ResourceGroupName = exampleAzurermResourceGroup.Name,
        IothubName = exampleAzurermIothub.Name,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.iot.IotFunctions;
import com.pulumi.azure.iot.inputs.GetSharedAccessPolicyArgs;
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) {
        final var example = IotFunctions.getSharedAccessPolicy(GetSharedAccessPolicyArgs.builder()
            .name("example")
            .resourceGroupName(exampleAzurermResourceGroup.name())
            .iothubName(exampleAzurermIothub.name())
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: azure:iot:getSharedAccessPolicy
      arguments:
        name: example
        resourceGroupName: ${exampleAzurermResourceGroup.name}
        iothubName: ${exampleAzurermIothub.name}
Copy

Using getSharedAccessPolicy

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getSharedAccessPolicy(args: GetSharedAccessPolicyArgs, opts?: InvokeOptions): Promise<GetSharedAccessPolicyResult>
function getSharedAccessPolicyOutput(args: GetSharedAccessPolicyOutputArgs, opts?: InvokeOptions): Output<GetSharedAccessPolicyResult>
Copy
def get_shared_access_policy(iothub_name: Optional[str] = None,
                             name: Optional[str] = None,
                             resource_group_name: Optional[str] = None,
                             opts: Optional[InvokeOptions] = None) -> GetSharedAccessPolicyResult
def get_shared_access_policy_output(iothub_name: Optional[pulumi.Input[str]] = None,
                             name: Optional[pulumi.Input[str]] = None,
                             resource_group_name: Optional[pulumi.Input[str]] = None,
                             opts: Optional[InvokeOptions] = None) -> Output[GetSharedAccessPolicyResult]
Copy
func LookupSharedAccessPolicy(ctx *Context, args *LookupSharedAccessPolicyArgs, opts ...InvokeOption) (*LookupSharedAccessPolicyResult, error)
func LookupSharedAccessPolicyOutput(ctx *Context, args *LookupSharedAccessPolicyOutputArgs, opts ...InvokeOption) LookupSharedAccessPolicyResultOutput
Copy

> Note: This function is named LookupSharedAccessPolicy in the Go SDK.

public static class GetSharedAccessPolicy 
{
    public static Task<GetSharedAccessPolicyResult> InvokeAsync(GetSharedAccessPolicyArgs args, InvokeOptions? opts = null)
    public static Output<GetSharedAccessPolicyResult> Invoke(GetSharedAccessPolicyInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetSharedAccessPolicyResult> getSharedAccessPolicy(GetSharedAccessPolicyArgs args, InvokeOptions options)
public static Output<GetSharedAccessPolicyResult> getSharedAccessPolicy(GetSharedAccessPolicyArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: azure:iot/getSharedAccessPolicy:getSharedAccessPolicy
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

IothubName This property is required. string
The name of the IoTHub to which this Shared Access Policy belongs.
Name This property is required. string
Specifies the name of the IotHub Shared Access Policy resource.
ResourceGroupName This property is required. string
The name of the resource group under which the IotHub Shared Access Policy resource has to be created.
IothubName This property is required. string
The name of the IoTHub to which this Shared Access Policy belongs.
Name This property is required. string
Specifies the name of the IotHub Shared Access Policy resource.
ResourceGroupName This property is required. string
The name of the resource group under which the IotHub Shared Access Policy resource has to be created.
iothubName This property is required. String
The name of the IoTHub to which this Shared Access Policy belongs.
name This property is required. String
Specifies the name of the IotHub Shared Access Policy resource.
resourceGroupName This property is required. String
The name of the resource group under which the IotHub Shared Access Policy resource has to be created.
iothubName This property is required. string
The name of the IoTHub to which this Shared Access Policy belongs.
name This property is required. string
Specifies the name of the IotHub Shared Access Policy resource.
resourceGroupName This property is required. string
The name of the resource group under which the IotHub Shared Access Policy resource has to be created.
iothub_name This property is required. str
The name of the IoTHub to which this Shared Access Policy belongs.
name This property is required. str
Specifies the name of the IotHub Shared Access Policy resource.
resource_group_name This property is required. str
The name of the resource group under which the IotHub Shared Access Policy resource has to be created.
iothubName This property is required. String
The name of the IoTHub to which this Shared Access Policy belongs.
name This property is required. String
Specifies the name of the IotHub Shared Access Policy resource.
resourceGroupName This property is required. String
The name of the resource group under which the IotHub Shared Access Policy resource has to be created.

getSharedAccessPolicy Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
IothubName string
Name string
PrimaryConnectionString string
The primary connection string of the Shared Access Policy.
PrimaryKey string
The primary key used to create the authentication token.
ResourceGroupName string
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.
IothubName string
Name string
PrimaryConnectionString string
The primary connection string of the Shared Access Policy.
PrimaryKey string
The primary key used to create the authentication token.
ResourceGroupName string
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.
iothubName String
name String
primaryConnectionString String
The primary connection string of the Shared Access Policy.
primaryKey String
The primary key used to create the authentication token.
resourceGroupName String
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.
iothubName string
name string
primaryConnectionString string
The primary connection string of the Shared Access Policy.
primaryKey string
The primary key used to create the authentication token.
resourceGroupName string
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.
iothub_name str
name str
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.
resource_group_name str
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.
iothubName String
name String
primaryConnectionString String
The primary connection string of the Shared Access Policy.
primaryKey String
The primary key used to create the authentication token.
resourceGroupName String
secondaryConnectionString String
The secondary connection string of the Shared Access Policy.
secondaryKey String
The secondary key used to create the authentication token.

Package Details

Repository
Azure Classic pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi