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

azuread.GroupMember

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 group membership within Azure Active Directory.

    Warning Do not use this resource at the same time as the members property of the azuread.Group resource for the same group. Doing so will cause a conflict and group members will be removed.

    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: Group.ReadWrite.All or Directory.ReadWrite.All.

    However, if the authenticated service principal is an owner of the group being managed, an application role is not required.

    When authenticated with a user principal, this resource requires one of the following directory roles: Groups Administrator, User 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 exampleGroup = new azuread.Group("example", {
        displayName: "my_group",
        securityEnabled: true,
    });
    const exampleGroupMember = new azuread.GroupMember("example", {
        groupObjectId: exampleGroup.id,
        memberObjectId: example.then(example => example.id),
    });
    
    import pulumi
    import pulumi_azuread as azuread
    
    example = azuread.get_user(user_principal_name="jdoe@example.com")
    example_group = azuread.Group("example",
        display_name="my_group",
        security_enabled=True)
    example_group_member = azuread.GroupMember("example",
        group_object_id=example_group.id,
        member_object_id=example.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
    		}
    		exampleGroup, err := azuread.NewGroup(ctx, "example", &azuread.GroupArgs{
    			DisplayName:     pulumi.String("my_group"),
    			SecurityEnabled: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = azuread.NewGroupMember(ctx, "example", &azuread.GroupMemberArgs{
    			GroupObjectId:  exampleGroup.ID(),
    			MemberObjectId: pulumi.String(example.Id),
    		})
    		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 exampleGroup = new AzureAD.Group("example", new()
        {
            DisplayName = "my_group",
            SecurityEnabled = true,
        });
    
        var exampleGroupMember = new AzureAD.GroupMember("example", new()
        {
            GroupObjectId = exampleGroup.Id,
            MemberObjectId = example.Apply(getUserResult => getUserResult.Id),
        });
    
    });
    
    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.Group;
    import com.pulumi.azuread.GroupArgs;
    import com.pulumi.azuread.GroupMember;
    import com.pulumi.azuread.GroupMemberArgs;
    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 exampleGroup = new Group("exampleGroup", GroupArgs.builder()
                .displayName("my_group")
                .securityEnabled(true)
                .build());
    
            var exampleGroupMember = new GroupMember("exampleGroupMember", GroupMemberArgs.builder()
                .groupObjectId(exampleGroup.id())
                .memberObjectId(example.applyValue(getUserResult -> getUserResult.id()))
                .build());
    
        }
    }
    
    resources:
      exampleGroup:
        type: azuread:Group
        name: example
        properties:
          displayName: my_group
          securityEnabled: true
      exampleGroupMember:
        type: azuread:GroupMember
        name: example
        properties:
          groupObjectId: ${exampleGroup.id}
          memberObjectId: ${example.id}
    variables:
      example:
        fn::invoke:
          Function: azuread:getUser
          Arguments:
            userPrincipalName: jdoe@example.com
    

    Create GroupMember Resource

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

    Constructor syntax

    new GroupMember(name: string, args: GroupMemberArgs, opts?: CustomResourceOptions);
    @overload
    def GroupMember(resource_name: str,
                    args: GroupMemberArgs,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def GroupMember(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    group_object_id: Optional[str] = None,
                    member_object_id: Optional[str] = None)
    func NewGroupMember(ctx *Context, name string, args GroupMemberArgs, opts ...ResourceOption) (*GroupMember, error)
    public GroupMember(string name, GroupMemberArgs args, CustomResourceOptions? opts = null)
    public GroupMember(String name, GroupMemberArgs args)
    public GroupMember(String name, GroupMemberArgs args, CustomResourceOptions options)
    
    type: azuread:GroupMember
    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 GroupMemberArgs
    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 GroupMemberArgs
    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 GroupMemberArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GroupMemberArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GroupMemberArgs
    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 groupMemberResource = new AzureAD.GroupMember("groupMemberResource", new()
    {
        GroupObjectId = "string",
        MemberObjectId = "string",
    });
    
    example, err := azuread.NewGroupMember(ctx, "groupMemberResource", &azuread.GroupMemberArgs{
    	GroupObjectId:  pulumi.String("string"),
    	MemberObjectId: pulumi.String("string"),
    })
    
    var groupMemberResource = new GroupMember("groupMemberResource", GroupMemberArgs.builder()
        .groupObjectId("string")
        .memberObjectId("string")
        .build());
    
    group_member_resource = azuread.GroupMember("groupMemberResource",
        group_object_id="string",
        member_object_id="string")
    
    const groupMemberResource = new azuread.GroupMember("groupMemberResource", {
        groupObjectId: "string",
        memberObjectId: "string",
    });
    
    type: azuread:GroupMember
    properties:
        groupObjectId: string
        memberObjectId: string
    

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

    GroupObjectId string
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    GroupObjectId string
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    groupObjectId String
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    groupObjectId string
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    group_object_id str
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    groupObjectId String
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the GroupMember 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 GroupMember Resource

    Get an existing GroupMember 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?: GroupMemberState, opts?: CustomResourceOptions): GroupMember
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            group_object_id: Optional[str] = None,
            member_object_id: Optional[str] = None) -> GroupMember
    func GetGroupMember(ctx *Context, name string, id IDInput, state *GroupMemberState, opts ...ResourceOption) (*GroupMember, error)
    public static GroupMember Get(string name, Input<string> id, GroupMemberState? state, CustomResourceOptions? opts = null)
    public static GroupMember get(String name, Output<String> id, GroupMemberState 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:
    GroupObjectId string
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    GroupObjectId string
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    groupObjectId String
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    groupObjectId string
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    group_object_id str
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.
    groupObjectId String
    The object ID of the group 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 group. Supported object types are Users, Groups or Service Principals. Changing this forces a new resource to be created.

    Import

    Group members can be imported using the object ID of the group and the object ID of the member, e.g.

    $ pulumi import azuread:index/groupMember:GroupMember example 00000000-0000-0000-0000-000000000000/member/11111111-1111-1111-1111-111111111111
    

    -> This ID format is unique to Terraform and is composed of the Azure AD Group Object ID and the target Member Object ID in the format {GroupObjectID}/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