1. Packages
  2. Azure Active Directory (Azure AD)
  3. API Docs
  4. CustomDirectoryRole
Azure Active Directory (Azure AD) v6.2.0 published on Tuesday, Jan 21, 2025 by Pulumi

azuread.CustomDirectoryRole

Explore with Pulumi AI

Manages a Custom Directory Role within Azure Active Directory.

This resource is for managing custom directory roles. For management of built-in roles, see the azuread.DirectoryRole resource.

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

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

const example = new azuread.CustomDirectoryRole("example", {
    displayName: "My Custom Role",
    description: "Allows reading applications and updating groups",
    enabled: true,
    version: "1.0",
    permissions: [
        {
            allowedResourceActions: [
                "microsoft.directory/applications/basic/update",
                "microsoft.directory/applications/create",
                "microsoft.directory/applications/standard/read",
            ],
        },
        {
            allowedResourceActions: [
                "microsoft.directory/groups/allProperties/read",
                "microsoft.directory/groups/allProperties/read",
                "microsoft.directory/groups/basic/update",
                "microsoft.directory/groups/create",
                "microsoft.directory/groups/delete",
            ],
        },
    ],
});
Copy
import pulumi
import pulumi_azuread as azuread

example = azuread.CustomDirectoryRole("example",
    display_name="My Custom Role",
    description="Allows reading applications and updating groups",
    enabled=True,
    version="1.0",
    permissions=[
        {
            "allowed_resource_actions": [
                "microsoft.directory/applications/basic/update",
                "microsoft.directory/applications/create",
                "microsoft.directory/applications/standard/read",
            ],
        },
        {
            "allowed_resource_actions": [
                "microsoft.directory/groups/allProperties/read",
                "microsoft.directory/groups/allProperties/read",
                "microsoft.directory/groups/basic/update",
                "microsoft.directory/groups/create",
                "microsoft.directory/groups/delete",
            ],
        },
    ])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := azuread.NewCustomDirectoryRole(ctx, "example", &azuread.CustomDirectoryRoleArgs{
			DisplayName: pulumi.String("My Custom Role"),
			Description: pulumi.String("Allows reading applications and updating groups"),
			Enabled:     pulumi.Bool(true),
			Version:     pulumi.String("1.0"),
			Permissions: azuread.CustomDirectoryRolePermissionArray{
				&azuread.CustomDirectoryRolePermissionArgs{
					AllowedResourceActions: pulumi.StringArray{
						pulumi.String("microsoft.directory/applications/basic/update"),
						pulumi.String("microsoft.directory/applications/create"),
						pulumi.String("microsoft.directory/applications/standard/read"),
					},
				},
				&azuread.CustomDirectoryRolePermissionArgs{
					AllowedResourceActions: pulumi.StringArray{
						pulumi.String("microsoft.directory/groups/allProperties/read"),
						pulumi.String("microsoft.directory/groups/allProperties/read"),
						pulumi.String("microsoft.directory/groups/basic/update"),
						pulumi.String("microsoft.directory/groups/create"),
						pulumi.String("microsoft.directory/groups/delete"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureAD = Pulumi.AzureAD;

return await Deployment.RunAsync(() => 
{
    var example = new AzureAD.CustomDirectoryRole("example", new()
    {
        DisplayName = "My Custom Role",
        Description = "Allows reading applications and updating groups",
        Enabled = true,
        Version = "1.0",
        Permissions = new[]
        {
            new AzureAD.Inputs.CustomDirectoryRolePermissionArgs
            {
                AllowedResourceActions = new[]
                {
                    "microsoft.directory/applications/basic/update",
                    "microsoft.directory/applications/create",
                    "microsoft.directory/applications/standard/read",
                },
            },
            new AzureAD.Inputs.CustomDirectoryRolePermissionArgs
            {
                AllowedResourceActions = new[]
                {
                    "microsoft.directory/groups/allProperties/read",
                    "microsoft.directory/groups/allProperties/read",
                    "microsoft.directory/groups/basic/update",
                    "microsoft.directory/groups/create",
                    "microsoft.directory/groups/delete",
                },
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuread.CustomDirectoryRole;
import com.pulumi.azuread.CustomDirectoryRoleArgs;
import com.pulumi.azuread.inputs.CustomDirectoryRolePermissionArgs;
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 CustomDirectoryRole("example", CustomDirectoryRoleArgs.builder()
            .displayName("My Custom Role")
            .description("Allows reading applications and updating groups")
            .enabled(true)
            .version("1.0")
            .permissions(            
                CustomDirectoryRolePermissionArgs.builder()
                    .allowedResourceActions(                    
                        "microsoft.directory/applications/basic/update",
                        "microsoft.directory/applications/create",
                        "microsoft.directory/applications/standard/read")
                    .build(),
                CustomDirectoryRolePermissionArgs.builder()
                    .allowedResourceActions(                    
                        "microsoft.directory/groups/allProperties/read",
                        "microsoft.directory/groups/allProperties/read",
                        "microsoft.directory/groups/basic/update",
                        "microsoft.directory/groups/create",
                        "microsoft.directory/groups/delete")
                    .build())
            .build());

    }
}
Copy
resources:
  example:
    type: azuread:CustomDirectoryRole
    properties:
      displayName: My Custom Role
      description: Allows reading applications and updating groups
      enabled: true
      version: '1.0'
      permissions:
        - allowedResourceActions:
            - microsoft.directory/applications/basic/update
            - microsoft.directory/applications/create
            - microsoft.directory/applications/standard/read
        - allowedResourceActions:
            - microsoft.directory/groups/allProperties/read
            - microsoft.directory/groups/allProperties/read
            - microsoft.directory/groups/basic/update
            - microsoft.directory/groups/create
            - microsoft.directory/groups/delete
Copy

Create CustomDirectoryRole Resource

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

Constructor syntax

new CustomDirectoryRole(name: string, args: CustomDirectoryRoleArgs, opts?: CustomResourceOptions);
@overload
def CustomDirectoryRole(resource_name: str,
                        args: CustomDirectoryRoleArgs,
                        opts: Optional[ResourceOptions] = None)

@overload
def CustomDirectoryRole(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        display_name: Optional[str] = None,
                        enabled: Optional[bool] = None,
                        permissions: Optional[Sequence[CustomDirectoryRolePermissionArgs]] = None,
                        version: Optional[str] = None,
                        description: Optional[str] = None,
                        template_id: Optional[str] = None)
func NewCustomDirectoryRole(ctx *Context, name string, args CustomDirectoryRoleArgs, opts ...ResourceOption) (*CustomDirectoryRole, error)
public CustomDirectoryRole(string name, CustomDirectoryRoleArgs args, CustomResourceOptions? opts = null)
public CustomDirectoryRole(String name, CustomDirectoryRoleArgs args)
public CustomDirectoryRole(String name, CustomDirectoryRoleArgs args, CustomResourceOptions options)
type: azuread:CustomDirectoryRole
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. CustomDirectoryRoleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. CustomDirectoryRoleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. CustomDirectoryRoleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. CustomDirectoryRoleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. CustomDirectoryRoleArgs
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 customDirectoryRoleResource = new AzureAD.CustomDirectoryRole("customDirectoryRoleResource", new()
{
    DisplayName = "string",
    Enabled = false,
    Permissions = new[]
    {
        new AzureAD.Inputs.CustomDirectoryRolePermissionArgs
        {
            AllowedResourceActions = new[]
            {
                "string",
            },
        },
    },
    Version = "string",
    Description = "string",
    TemplateId = "string",
});
Copy
example, err := azuread.NewCustomDirectoryRole(ctx, "customDirectoryRoleResource", &azuread.CustomDirectoryRoleArgs{
	DisplayName: pulumi.String("string"),
	Enabled:     pulumi.Bool(false),
	Permissions: azuread.CustomDirectoryRolePermissionArray{
		&azuread.CustomDirectoryRolePermissionArgs{
			AllowedResourceActions: pulumi.StringArray{
				pulumi.String("string"),
			},
		},
	},
	Version:     pulumi.String("string"),
	Description: pulumi.String("string"),
	TemplateId:  pulumi.String("string"),
})
Copy
var customDirectoryRoleResource = new CustomDirectoryRole("customDirectoryRoleResource", CustomDirectoryRoleArgs.builder()
    .displayName("string")
    .enabled(false)
    .permissions(CustomDirectoryRolePermissionArgs.builder()
        .allowedResourceActions("string")
        .build())
    .version("string")
    .description("string")
    .templateId("string")
    .build());
Copy
custom_directory_role_resource = azuread.CustomDirectoryRole("customDirectoryRoleResource",
    display_name="string",
    enabled=False,
    permissions=[{
        "allowed_resource_actions": ["string"],
    }],
    version="string",
    description="string",
    template_id="string")
Copy
const customDirectoryRoleResource = new azuread.CustomDirectoryRole("customDirectoryRoleResource", {
    displayName: "string",
    enabled: false,
    permissions: [{
        allowedResourceActions: ["string"],
    }],
    version: "string",
    description: "string",
    templateId: "string",
});
Copy
type: azuread:CustomDirectoryRole
properties:
    description: string
    displayName: string
    enabled: false
    permissions:
        - allowedResourceActions:
            - string
    templateId: string
    version: string
Copy

CustomDirectoryRole Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The CustomDirectoryRole resource accepts the following input properties:

DisplayName This property is required. string
The display name of the custom directory role.
Enabled This property is required. bool
Indicates whether the role is enabled for assignment.
Permissions This property is required. List<Pulumi.AzureAD.Inputs.CustomDirectoryRolePermission>
A collection of permissions blocks as documented below.
Version This property is required. string
The version of the role definition. This can be any arbitrary string between 1-128 characters.
Description string
The description of the custom directory role.
TemplateId Changes to this property will trigger replacement. string
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
DisplayName This property is required. string
The display name of the custom directory role.
Enabled This property is required. bool
Indicates whether the role is enabled for assignment.
Permissions This property is required. []CustomDirectoryRolePermissionArgs
A collection of permissions blocks as documented below.
Version This property is required. string
The version of the role definition. This can be any arbitrary string between 1-128 characters.
Description string
The description of the custom directory role.
TemplateId Changes to this property will trigger replacement. string
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
displayName This property is required. String
The display name of the custom directory role.
enabled This property is required. Boolean
Indicates whether the role is enabled for assignment.
permissions This property is required. List<CustomDirectoryRolePermission>
A collection of permissions blocks as documented below.
version This property is required. String
The version of the role definition. This can be any arbitrary string between 1-128 characters.
description String
The description of the custom directory role.
templateId Changes to this property will trigger replacement. String
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
displayName This property is required. string
The display name of the custom directory role.
enabled This property is required. boolean
Indicates whether the role is enabled for assignment.
permissions This property is required. CustomDirectoryRolePermission[]
A collection of permissions blocks as documented below.
version This property is required. string
The version of the role definition. This can be any arbitrary string between 1-128 characters.
description string
The description of the custom directory role.
templateId Changes to this property will trigger replacement. string
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
display_name This property is required. str
The display name of the custom directory role.
enabled This property is required. bool
Indicates whether the role is enabled for assignment.
permissions This property is required. Sequence[CustomDirectoryRolePermissionArgs]
A collection of permissions blocks as documented below.
version This property is required. str
The version of the role definition. This can be any arbitrary string between 1-128 characters.
description str
The description of the custom directory role.
template_id Changes to this property will trigger replacement. str
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
displayName This property is required. String
The display name of the custom directory role.
enabled This property is required. Boolean
Indicates whether the role is enabled for assignment.
permissions This property is required. List<Property Map>
A collection of permissions blocks as documented below.
version This property is required. String
The version of the role definition. This can be any arbitrary string between 1-128 characters.
description String
The description of the custom directory role.
templateId Changes to this property will trigger replacement. String
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.

Outputs

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

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

Look up Existing CustomDirectoryRole Resource

Get an existing CustomDirectoryRole 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?: CustomDirectoryRoleState, opts?: CustomResourceOptions): CustomDirectoryRole
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        description: Optional[str] = None,
        display_name: Optional[str] = None,
        enabled: Optional[bool] = None,
        object_id: Optional[str] = None,
        permissions: Optional[Sequence[CustomDirectoryRolePermissionArgs]] = None,
        template_id: Optional[str] = None,
        version: Optional[str] = None) -> CustomDirectoryRole
func GetCustomDirectoryRole(ctx *Context, name string, id IDInput, state *CustomDirectoryRoleState, opts ...ResourceOption) (*CustomDirectoryRole, error)
public static CustomDirectoryRole Get(string name, Input<string> id, CustomDirectoryRoleState? state, CustomResourceOptions? opts = null)
public static CustomDirectoryRole get(String name, Output<String> id, CustomDirectoryRoleState state, CustomResourceOptions options)
resources:  _:    type: azuread:CustomDirectoryRole    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 custom directory role.
DisplayName string
The display name of the custom directory role.
Enabled bool
Indicates whether the role is enabled for assignment.
ObjectId string
The object ID of the custom directory role.
Permissions List<Pulumi.AzureAD.Inputs.CustomDirectoryRolePermission>
A collection of permissions blocks as documented below.
TemplateId Changes to this property will trigger replacement. string
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
Version string
The version of the role definition. This can be any arbitrary string between 1-128 characters.
Description string
The description of the custom directory role.
DisplayName string
The display name of the custom directory role.
Enabled bool
Indicates whether the role is enabled for assignment.
ObjectId string
The object ID of the custom directory role.
Permissions []CustomDirectoryRolePermissionArgs
A collection of permissions blocks as documented below.
TemplateId Changes to this property will trigger replacement. string
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
Version string
The version of the role definition. This can be any arbitrary string between 1-128 characters.
description String
The description of the custom directory role.
displayName String
The display name of the custom directory role.
enabled Boolean
Indicates whether the role is enabled for assignment.
objectId String
The object ID of the custom directory role.
permissions List<CustomDirectoryRolePermission>
A collection of permissions blocks as documented below.
templateId Changes to this property will trigger replacement. String
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
version String
The version of the role definition. This can be any arbitrary string between 1-128 characters.
description string
The description of the custom directory role.
displayName string
The display name of the custom directory role.
enabled boolean
Indicates whether the role is enabled for assignment.
objectId string
The object ID of the custom directory role.
permissions CustomDirectoryRolePermission[]
A collection of permissions blocks as documented below.
templateId Changes to this property will trigger replacement. string
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
version string
The version of the role definition. This can be any arbitrary string between 1-128 characters.
description str
The description of the custom directory role.
display_name str
The display name of the custom directory role.
enabled bool
Indicates whether the role is enabled for assignment.
object_id str
The object ID of the custom directory role.
permissions Sequence[CustomDirectoryRolePermissionArgs]
A collection of permissions blocks as documented below.
template_id Changes to this property will trigger replacement. str
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
version str
The version of the role definition. This can be any arbitrary string between 1-128 characters.
description String
The description of the custom directory role.
displayName String
The display name of the custom directory role.
enabled Boolean
Indicates whether the role is enabled for assignment.
objectId String
The object ID of the custom directory role.
permissions List<Property Map>
A collection of permissions blocks as documented below.
templateId Changes to this property will trigger replacement. String
Custom template identifier that is typically used if one needs an identifier to be the same across different directories. Changing this forces a new resource to be created.
version String
The version of the role definition. This can be any arbitrary string between 1-128 characters.

Supporting Types

CustomDirectoryRolePermission
, CustomDirectoryRolePermissionArgs

AllowedResourceActions This property is required. List<string>
A set of tasks that can be performed on a resource. For more information, see the Permissions Reference documentation.
AllowedResourceActions This property is required. []string
A set of tasks that can be performed on a resource. For more information, see the Permissions Reference documentation.
allowedResourceActions This property is required. List<String>
A set of tasks that can be performed on a resource. For more information, see the Permissions Reference documentation.
allowedResourceActions This property is required. string[]
A set of tasks that can be performed on a resource. For more information, see the Permissions Reference documentation.
allowed_resource_actions This property is required. Sequence[str]
A set of tasks that can be performed on a resource. For more information, see the Permissions Reference documentation.
allowedResourceActions This property is required. List<String>
A set of tasks that can be performed on a resource. For more information, see the Permissions Reference documentation.

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.