1. Packages
  2. Azure Active Directory (Azure AD)
  3. API Docs
  4. DirectoryRole
Azure Active Directory (Azure AD) v5.52.0 published on Friday, Jun 14, 2024 by Pulumi

azuread.DirectoryRole

Explore with Pulumi AI

azuread logo
Azure Active Directory (Azure AD) v5.52.0 published on Friday, Jun 14, 2024 by Pulumi

    Manages a Directory Role within Azure Active Directory. Directory Roles are also known as Administrator Roles.

    Directory Roles are built-in to Azure Active Directory and are immutable. However, by default they are not activated in a tenant (except for the Global Administrator role). This resource ensures a directory role is activated from its associated role template, and exports the object ID of the role, so that role assignments can be made for it.

    Once activated, directory roles cannot be deactivated and so this resource does not perform any actions on destroy.

    API Permissions

    The following API permissions are required in order to use this resource.

    When authenticated with a service principal, this resource requires one of the following application roles: RoleManagement.ReadWrite.Directory or Directory.ReadWrite.All

    When authenticated with a user principal, this resource requires one of the following directory roles: Privileged Role Administrator or Global Administrator

    Example Usage

    Activate a directory role by its template ID

    import * as pulumi from "@pulumi/pulumi";
    import * as azuread from "@pulumi/azuread";
    
    const example = new azuread.DirectoryRole("example", {templateId: "00000000-0000-0000-0000-000000000000"});
    
    import pulumi
    import pulumi_azuread as azuread
    
    example = azuread.DirectoryRole("example", template_id="00000000-0000-0000-0000-000000000000")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azuread/sdk/v5/go/azuread"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := azuread.NewDirectoryRole(ctx, "example", &azuread.DirectoryRoleArgs{
    			TemplateId: pulumi.String("00000000-0000-0000-0000-000000000000"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureAD = Pulumi.AzureAD;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new AzureAD.DirectoryRole("example", new()
        {
            TemplateId = "00000000-0000-0000-0000-000000000000",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azuread.DirectoryRole;
    import com.pulumi.azuread.DirectoryRoleArgs;
    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 example = new DirectoryRole("example", DirectoryRoleArgs.builder()
                .templateId("00000000-0000-0000-0000-000000000000")
                .build());
    
        }
    }
    
    resources:
      example:
        type: azuread:DirectoryRole
        properties:
          templateId: 00000000-0000-0000-0000-000000000000
    

    Activate a directory role by display name

    import * as pulumi from "@pulumi/pulumi";
    import * as azuread from "@pulumi/azuread";
    
    const example = new azuread.DirectoryRole("example", {displayName: "Printer administrator"});
    
    import pulumi
    import pulumi_azuread as azuread
    
    example = azuread.DirectoryRole("example", display_name="Printer administrator")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azuread/sdk/v5/go/azuread"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := azuread.NewDirectoryRole(ctx, "example", &azuread.DirectoryRoleArgs{
    			DisplayName: pulumi.String("Printer administrator"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureAD = Pulumi.AzureAD;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new AzureAD.DirectoryRole("example", new()
        {
            DisplayName = "Printer administrator",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azuread.DirectoryRole;
    import com.pulumi.azuread.DirectoryRoleArgs;
    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 example = new DirectoryRole("example", DirectoryRoleArgs.builder()
                .displayName("Printer administrator")
                .build());
    
        }
    }
    
    resources:
      example:
        type: azuread:DirectoryRole
        properties:
          displayName: Printer administrator
    

    Create DirectoryRole Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new DirectoryRole(name: string, args?: DirectoryRoleArgs, opts?: CustomResourceOptions);
    @overload
    def DirectoryRole(resource_name: str,
                      args: Optional[DirectoryRoleArgs] = None,
                      opts: Optional[ResourceOptions] = None)
    
    @overload
    def DirectoryRole(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      display_name: Optional[str] = None,
                      template_id: Optional[str] = None)
    func NewDirectoryRole(ctx *Context, name string, args *DirectoryRoleArgs, opts ...ResourceOption) (*DirectoryRole, error)
    public DirectoryRole(string name, DirectoryRoleArgs? args = null, CustomResourceOptions? opts = null)
    public DirectoryRole(String name, DirectoryRoleArgs args)
    public DirectoryRole(String name, DirectoryRoleArgs args, CustomResourceOptions options)
    
    type: azuread:DirectoryRole
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args DirectoryRoleArgs
    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 DirectoryRoleArgs
    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 DirectoryRoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DirectoryRoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DirectoryRoleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var directoryRoleResource = new AzureAD.DirectoryRole("directoryRoleResource", new()
    {
        DisplayName = "string",
        TemplateId = "string",
    });
    
    example, err := azuread.NewDirectoryRole(ctx, "directoryRoleResource", &azuread.DirectoryRoleArgs{
    	DisplayName: pulumi.String("string"),
    	TemplateId:  pulumi.String("string"),
    })
    
    var directoryRoleResource = new DirectoryRole("directoryRoleResource", DirectoryRoleArgs.builder()
        .displayName("string")
        .templateId("string")
        .build());
    
    directory_role_resource = azuread.DirectoryRole("directoryRoleResource",
        display_name="string",
        template_id="string")
    
    const directoryRoleResource = new azuread.DirectoryRole("directoryRoleResource", {
        displayName: "string",
        templateId: "string",
    });
    
    type: azuread:DirectoryRole
    properties:
        displayName: string
        templateId: string
    

    DirectoryRole 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 DirectoryRole resource accepts the following input properties:

    DisplayName string
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    TemplateId string

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    DisplayName string
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    TemplateId string

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    displayName String
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    templateId String

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    displayName string
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    templateId string

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    display_name str
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    template_id str

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    displayName String
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    templateId String

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    Outputs

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

    Description string
    The description of the directory role.
    Id string
    The provider-assigned unique ID for this managed resource.
    ObjectId string
    The object ID of the directory role.
    Description string
    The description of the directory role.
    Id string
    The provider-assigned unique ID for this managed resource.
    ObjectId string
    The object ID of the directory role.
    description String
    The description of the directory role.
    id String
    The provider-assigned unique ID for this managed resource.
    objectId String
    The object ID of the directory role.
    description string
    The description of the directory role.
    id string
    The provider-assigned unique ID for this managed resource.
    objectId string
    The object ID of the directory role.
    description str
    The description of the directory role.
    id str
    The provider-assigned unique ID for this managed resource.
    object_id str
    The object ID of the directory role.
    description String
    The description of the directory role.
    id String
    The provider-assigned unique ID for this managed resource.
    objectId String
    The object ID of the directory role.

    Look up Existing DirectoryRole Resource

    Get an existing DirectoryRole 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?: DirectoryRoleState, opts?: CustomResourceOptions): DirectoryRole
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            display_name: Optional[str] = None,
            object_id: Optional[str] = None,
            template_id: Optional[str] = None) -> DirectoryRole
    func GetDirectoryRole(ctx *Context, name string, id IDInput, state *DirectoryRoleState, opts ...ResourceOption) (*DirectoryRole, error)
    public static DirectoryRole Get(string name, Input<string> id, DirectoryRoleState? state, CustomResourceOptions? opts = null)
    public static DirectoryRole get(String name, Output<String> id, DirectoryRoleState 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:
    Description string
    The description of the directory role.
    DisplayName string
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    ObjectId string
    The object ID of the directory role.
    TemplateId string

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    Description string
    The description of the directory role.
    DisplayName string
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    ObjectId string
    The object ID of the directory role.
    TemplateId string

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    description String
    The description of the directory role.
    displayName String
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    objectId String
    The object ID of the directory role.
    templateId String

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    description string
    The description of the directory role.
    displayName string
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    objectId string
    The object ID of the directory role.
    templateId string

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    description str
    The description of the directory role.
    display_name str
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    object_id str
    The object ID of the directory role.
    template_id str

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    description String
    The description of the directory role.
    displayName String
    The display name of the directory role to activate. Changing this forces a new resource to be created.
    objectId String
    The object ID of the directory role.
    templateId String

    The object ID of the role template from which to activate the directory role. Changing this forces a new resource to be created.

    Either display_name or template_id must be specified.

    Import

    This resource does not support importing.

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Azure Active Directory (Azure AD) pulumi/pulumi-azuread
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azuread Terraform Provider.
    azuread logo
    Azure Active Directory (Azure AD) v5.52.0 published on Friday, Jun 14, 2024 by Pulumi