1. Packages
  2. Azure Active Directory (Azure AD)
  3. API Docs
  4. DirectoryRoleMember
Azure Active Directory (Azure AD) v6.0.1 published on Monday, Oct 14, 2024 by Pulumi

azuread.DirectoryRoleMember

Explore with Pulumi AI

azuread logo
Azure Active Directory (Azure AD) v6.0.1 published on Monday, Oct 14, 2024 by Pulumi

    Manages a single directory role membership (assignment) within Azure Active Directory.

    Deprecation Warning: This resource has been superseded by the azuread.DirectoryRoleAssignment resource and will be removed in version 3.0 of the AzureAD provider

    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 = azuread.getUser({
        userPrincipalName: "jdoe@example.com",
    });
    const exampleDirectoryRole = new azuread.DirectoryRole("example", {displayName: "Security administrator"});
    const exampleDirectoryRoleMember = new azuread.DirectoryRoleMember("example", {
        roleObjectId: exampleDirectoryRole.objectId,
        memberObjectId: example.then(example => example.objectId),
    });
    
    import pulumi
    import pulumi_azuread as azuread
    
    example = azuread.get_user(user_principal_name="jdoe@example.com")
    example_directory_role = azuread.DirectoryRole("example", display_name="Security administrator")
    example_directory_role_member = azuread.DirectoryRoleMember("example",
        role_object_id=example_directory_role.object_id,
        member_object_id=example.object_id)
    
    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 {
    		example, err := azuread.LookupUser(ctx, &azuread.LookupUserArgs{
    			UserPrincipalName: pulumi.StringRef("jdoe@example.com"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleDirectoryRole, err := azuread.NewDirectoryRole(ctx, "example", &azuread.DirectoryRoleArgs{
    			DisplayName: pulumi.String("Security administrator"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = azuread.NewDirectoryRoleMember(ctx, "example", &azuread.DirectoryRoleMemberArgs{
    			RoleObjectId:   exampleDirectoryRole.ObjectId,
    			MemberObjectId: pulumi.String(example.ObjectId),
    		})
    		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 = AzureAD.GetUser.Invoke(new()
        {
            UserPrincipalName = "jdoe@example.com",
        });
    
        var exampleDirectoryRole = new AzureAD.DirectoryRole("example", new()
        {
            DisplayName = "Security administrator",
        });
    
        var exampleDirectoryRoleMember = new AzureAD.DirectoryRoleMember("example", new()
        {
            RoleObjectId = exampleDirectoryRole.ObjectId,
            MemberObjectId = example.Apply(getUserResult => getUserResult.ObjectId),
        });
    
    });
    
    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 example = AzureadFunctions.getUser(GetUserArgs.builder()
                .userPrincipalName("jdoe@example.com")
                .build());
    
            var exampleDirectoryRole = new DirectoryRole("exampleDirectoryRole", DirectoryRoleArgs.builder()
                .displayName("Security administrator")
                .build());
    
            var exampleDirectoryRoleMember = new DirectoryRoleMember("exampleDirectoryRoleMember", DirectoryRoleMemberArgs.builder()
                .roleObjectId(exampleDirectoryRole.objectId())
                .memberObjectId(example.applyValue(getUserResult -> getUserResult.objectId()))
                .build());
    
        }
    }
    
    resources:
      exampleDirectoryRole:
        type: azuread:DirectoryRole
        name: example
        properties:
          displayName: Security administrator
      exampleDirectoryRoleMember:
        type: azuread:DirectoryRoleMember
        name: example
        properties:
          roleObjectId: ${exampleDirectoryRole.objectId}
          memberObjectId: ${example.objectId}
    variables:
      example:
        fn::invoke:
          Function: azuread:getUser
          Arguments:
            userPrincipalName: jdoe@example.com
    

    Create DirectoryRoleMember Resource

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

    Constructor syntax

    new DirectoryRoleMember(name: string, args?: DirectoryRoleMemberArgs, opts?: CustomResourceOptions);
    @overload
    def DirectoryRoleMember(resource_name: str,
                            args: Optional[DirectoryRoleMemberArgs] = None,
                            opts: Optional[ResourceOptions] = None)
    
    @overload
    def DirectoryRoleMember(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            member_object_id: Optional[str] = None,
                            role_object_id: Optional[str] = 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.
    
    

    Parameters

    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.

    Constructor example

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

    var directoryRoleMemberResource = new AzureAD.DirectoryRoleMember("directoryRoleMemberResource", new()
    {
        MemberObjectId = "string",
        RoleObjectId = "string",
    });
    
    example, err := azuread.NewDirectoryRoleMember(ctx, "directoryRoleMemberResource", &azuread.DirectoryRoleMemberArgs{
    	MemberObjectId: pulumi.String("string"),
    	RoleObjectId:   pulumi.String("string"),
    })
    
    var directoryRoleMemberResource = new DirectoryRoleMember("directoryRoleMemberResource", DirectoryRoleMemberArgs.builder()
        .memberObjectId("string")
        .roleObjectId("string")
        .build());
    
    directory_role_member_resource = azuread.DirectoryRoleMember("directoryRoleMemberResource",
        member_object_id="string",
        role_object_id="string")
    
    const directoryRoleMemberResource = new azuread.DirectoryRoleMember("directoryRoleMemberResource", {
        memberObjectId: "string",
        roleObjectId: "string",
    });
    
    type: azuread:DirectoryRoleMember
    properties:
        memberObjectId: string
        roleObjectId: string
    

    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

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

    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.

    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 example 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}.

    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) v6.0.1 published on Monday, Oct 14, 2024 by Pulumi