azuread logo
Azure Active Directory (Azure AD) v5.36.0, Mar 7 23

azuread.DirectoryRoleMember

Import

Directory role members can be imported using the object ID of the role and the object ID of the member, e.g.

 $ pulumi import azuread:index/directoryRoleMember:DirectoryRoleMember test 00000000-0000-0000-0000-000000000000/member/11111111-1111-1111-1111-111111111111

-> This ID format is unique to Terraform and is composed of the Directory Role Object ID and the target Member Object ID in the format {RoleObjectID}/member/{MemberObjectID}.

Example Usage

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

return await Deployment.RunAsync(() => 
{
    var exampleUser = AzureAD.GetUser.Invoke(new()
    {
        UserPrincipalName = "jdoe@hashicorp.com",
    });

    var exampleDirectoryRole = new AzureAD.DirectoryRole("exampleDirectoryRole", new()
    {
        DisplayName = "Security administrator",
    });

    var exampleDirectoryRoleMember = new AzureAD.DirectoryRoleMember("exampleDirectoryRoleMember", new()
    {
        RoleObjectId = exampleDirectoryRole.ObjectId,
        MemberObjectId = exampleUser.Apply(getUserResult => getUserResult.ObjectId),
    });

});
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 {
		exampleUser, err := azuread.LookupUser(ctx, &azuread.LookupUserArgs{
			UserPrincipalName: pulumi.StringRef("jdoe@hashicorp.com"),
		}, nil)
		if err != nil {
			return err
		}
		exampleDirectoryRole, err := azuread.NewDirectoryRole(ctx, "exampleDirectoryRole", &azuread.DirectoryRoleArgs{
			DisplayName: pulumi.String("Security administrator"),
		})
		if err != nil {
			return err
		}
		_, err = azuread.NewDirectoryRoleMember(ctx, "exampleDirectoryRoleMember", &azuread.DirectoryRoleMemberArgs{
			RoleObjectId:   exampleDirectoryRole.ObjectId,
			MemberObjectId: *pulumi.String(exampleUser.ObjectId),
		})
		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.azuread.AzureadFunctions;
import com.pulumi.azuread.inputs.GetUserArgs;
import com.pulumi.azuread.DirectoryRole;
import com.pulumi.azuread.DirectoryRoleArgs;
import com.pulumi.azuread.DirectoryRoleMember;
import com.pulumi.azuread.DirectoryRoleMemberArgs;
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 exampleUser = AzureadFunctions.getUser(GetUserArgs.builder()
            .userPrincipalName("jdoe@hashicorp.com")
            .build());

        var exampleDirectoryRole = new DirectoryRole("exampleDirectoryRole", DirectoryRoleArgs.builder()        
            .displayName("Security administrator")
            .build());

        var exampleDirectoryRoleMember = new DirectoryRoleMember("exampleDirectoryRoleMember", DirectoryRoleMemberArgs.builder()        
            .roleObjectId(exampleDirectoryRole.objectId())
            .memberObjectId(exampleUser.applyValue(getUserResult -> getUserResult.objectId()))
            .build());

    }
}
import pulumi
import pulumi_azuread as azuread

example_user = azuread.get_user(user_principal_name="jdoe@hashicorp.com")
example_directory_role = azuread.DirectoryRole("exampleDirectoryRole", display_name="Security administrator")
example_directory_role_member = azuread.DirectoryRoleMember("exampleDirectoryRoleMember",
    role_object_id=example_directory_role.object_id,
    member_object_id=example_user.object_id)
import * as pulumi from "@pulumi/pulumi";
import * as azuread from "@pulumi/azuread";

const exampleUser = azuread.getUser({
    userPrincipalName: "jdoe@hashicorp.com",
});
const exampleDirectoryRole = new azuread.DirectoryRole("exampleDirectoryRole", {displayName: "Security administrator"});
const exampleDirectoryRoleMember = new azuread.DirectoryRoleMember("exampleDirectoryRoleMember", {
    roleObjectId: exampleDirectoryRole.objectId,
    memberObjectId: exampleUser.then(exampleUser => exampleUser.objectId),
});
resources:
  exampleDirectoryRole:
    type: azuread:DirectoryRole
    properties:
      displayName: Security administrator
  exampleDirectoryRoleMember:
    type: azuread:DirectoryRoleMember
    properties:
      roleObjectId: ${exampleDirectoryRole.objectId}
      memberObjectId: ${exampleUser.objectId}
variables:
  exampleUser:
    fn::invoke:
      Function: azuread:getUser
      Arguments:
        userPrincipalName: jdoe@hashicorp.com

Create DirectoryRoleMember Resource

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

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

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

MemberObjectId string

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

RoleObjectId string

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

MemberObjectId string

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

RoleObjectId string

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

memberObjectId String

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

roleObjectId String

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

memberObjectId string

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

roleObjectId string

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

member_object_id str

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

role_object_id str

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

memberObjectId String

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

roleObjectId String

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

Outputs

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

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing DirectoryRoleMember Resource

Get an existing DirectoryRoleMember 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?: DirectoryRoleMemberState, opts?: CustomResourceOptions): DirectoryRoleMember
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        member_object_id: Optional[str] = None,
        role_object_id: Optional[str] = None) -> DirectoryRoleMember
func GetDirectoryRoleMember(ctx *Context, name string, id IDInput, state *DirectoryRoleMemberState, opts ...ResourceOption) (*DirectoryRoleMember, error)
public static DirectoryRoleMember Get(string name, Input<string> id, DirectoryRoleMemberState? state, CustomResourceOptions? opts = null)
public static DirectoryRoleMember get(String name, Output<String> id, DirectoryRoleMemberState 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:
MemberObjectId string

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

RoleObjectId string

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

MemberObjectId string

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

RoleObjectId string

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

memberObjectId String

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

roleObjectId String

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

memberObjectId string

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

roleObjectId string

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

member_object_id str

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

role_object_id str

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

memberObjectId String

The object ID of the principal you want to add as a member to the directory role. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

roleObjectId String

The object ID of the directory role you want to add the member to. Changing this forces a new resource to be created.

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.