1. Packages
  2. AzureDevOps
  3. API Docs
  4. GroupMembership
Azure DevOps v3.0.0 published on Friday, Mar 15, 2024 by Pulumi

azuredevops.GroupMembership

Explore with Pulumi AI

azuredevops logo
Azure DevOps v3.0.0 published on Friday, Mar 15, 2024 by Pulumi

    Manages group membership within Azure DevOps.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azuredevops from "@pulumi/azuredevops";
    
    const exampleProject = new azuredevops.Project("exampleProject", {});
    const exampleUser = new azuredevops.User("exampleUser", {principalName: "foo@contoso.com"});
    const exampleGroup = azuredevops.getGroupOutput({
        projectId: exampleProject.id,
        name: "Build Administrators",
    });
    const exampleGroupMembership = new azuredevops.GroupMembership("exampleGroupMembership", {
        group: exampleGroup.apply(exampleGroup => exampleGroup.descriptor),
        members: [exampleUser.descriptor],
    });
    
    import pulumi
    import pulumi_azuredevops as azuredevops
    
    example_project = azuredevops.Project("exampleProject")
    example_user = azuredevops.User("exampleUser", principal_name="foo@contoso.com")
    example_group = azuredevops.get_group_output(project_id=example_project.id,
        name="Build Administrators")
    example_group_membership = azuredevops.GroupMembership("exampleGroupMembership",
        group=example_group.descriptor,
        members=[example_user.descriptor])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azuredevops/sdk/v3/go/azuredevops"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleProject, err := azuredevops.NewProject(ctx, "exampleProject", nil)
    		if err != nil {
    			return err
    		}
    		exampleUser, err := azuredevops.NewUser(ctx, "exampleUser", &azuredevops.UserArgs{
    			PrincipalName: pulumi.String("foo@contoso.com"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleGroup := azuredevops.LookupGroupOutput(ctx, azuredevops.GetGroupOutputArgs{
    			ProjectId: exampleProject.ID(),
    			Name:      pulumi.String("Build Administrators"),
    		}, nil)
    		_, err = azuredevops.NewGroupMembership(ctx, "exampleGroupMembership", &azuredevops.GroupMembershipArgs{
    			Group: exampleGroup.ApplyT(func(exampleGroup azuredevops.GetGroupResult) (*string, error) {
    				return &exampleGroup.Descriptor, nil
    			}).(pulumi.StringPtrOutput),
    			Members: pulumi.StringArray{
    				exampleUser.Descriptor,
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AzureDevOps = Pulumi.AzureDevOps;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleProject = new AzureDevOps.Project("exampleProject");
    
        var exampleUser = new AzureDevOps.User("exampleUser", new()
        {
            PrincipalName = "foo@contoso.com",
        });
    
        var exampleGroup = AzureDevOps.GetGroup.Invoke(new()
        {
            ProjectId = exampleProject.Id,
            Name = "Build Administrators",
        });
    
        var exampleGroupMembership = new AzureDevOps.GroupMembership("exampleGroupMembership", new()
        {
            Group = exampleGroup.Apply(getGroupResult => getGroupResult.Descriptor),
            Members = new[]
            {
                exampleUser.Descriptor,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azuredevops.Project;
    import com.pulumi.azuredevops.User;
    import com.pulumi.azuredevops.UserArgs;
    import com.pulumi.azuredevops.AzuredevopsFunctions;
    import com.pulumi.azuredevops.inputs.GetGroupArgs;
    import com.pulumi.azuredevops.GroupMembership;
    import com.pulumi.azuredevops.GroupMembershipArgs;
    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 exampleProject = new Project("exampleProject");
    
            var exampleUser = new User("exampleUser", UserArgs.builder()        
                .principalName("foo@contoso.com")
                .build());
    
            final var exampleGroup = AzuredevopsFunctions.getGroup(GetGroupArgs.builder()
                .projectId(exampleProject.id())
                .name("Build Administrators")
                .build());
    
            var exampleGroupMembership = new GroupMembership("exampleGroupMembership", GroupMembershipArgs.builder()        
                .group(exampleGroup.applyValue(getGroupResult -> getGroupResult).applyValue(exampleGroup -> exampleGroup.applyValue(getGroupResult -> getGroupResult.descriptor())))
                .members(exampleUser.descriptor())
                .build());
    
        }
    }
    
    resources:
      exampleProject:
        type: azuredevops:Project
      exampleUser:
        type: azuredevops:User
        properties:
          principalName: foo@contoso.com
      exampleGroupMembership:
        type: azuredevops:GroupMembership
        properties:
          group: ${exampleGroup.descriptor}
          members:
            - ${exampleUser.descriptor}
    variables:
      exampleGroup:
        fn::invoke:
          Function: azuredevops:getGroup
          Arguments:
            projectId: ${exampleProject.id}
            name: Build Administrators
    

    PAT Permissions Required

    • Deployment Groups: Read & Manage

    Create GroupMembership Resource

    new GroupMembership(name: string, args: GroupMembershipArgs, opts?: CustomResourceOptions);
    @overload
    def GroupMembership(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        group: Optional[str] = None,
                        members: Optional[Sequence[str]] = None,
                        mode: Optional[str] = None)
    @overload
    def GroupMembership(resource_name: str,
                        args: GroupMembershipArgs,
                        opts: Optional[ResourceOptions] = None)
    func NewGroupMembership(ctx *Context, name string, args GroupMembershipArgs, opts ...ResourceOption) (*GroupMembership, error)
    public GroupMembership(string name, GroupMembershipArgs args, CustomResourceOptions? opts = null)
    public GroupMembership(String name, GroupMembershipArgs args)
    public GroupMembership(String name, GroupMembershipArgs args, CustomResourceOptions options)
    
    type: azuredevops:GroupMembership
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args GroupMembershipArgs
    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 GroupMembershipArgs
    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 GroupMembershipArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GroupMembershipArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GroupMembershipArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

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

    Group string
    The descriptor of the group being managed.
    Members List<string>

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    Mode string

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    Group string
    The descriptor of the group being managed.
    Members []string

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    Mode string

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    group String
    The descriptor of the group being managed.
    members List<String>

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    mode String

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    group string
    The descriptor of the group being managed.
    members string[]

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    mode string

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    group str
    The descriptor of the group being managed.
    members Sequence[str]

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    mode str

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    group String
    The descriptor of the group being managed.
    members List<String>

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    mode String

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    Outputs

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

    Get an existing GroupMembership 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?: GroupMembershipState, opts?: CustomResourceOptions): GroupMembership
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            group: Optional[str] = None,
            members: Optional[Sequence[str]] = None,
            mode: Optional[str] = None) -> GroupMembership
    func GetGroupMembership(ctx *Context, name string, id IDInput, state *GroupMembershipState, opts ...ResourceOption) (*GroupMembership, error)
    public static GroupMembership Get(string name, Input<string> id, GroupMembershipState? state, CustomResourceOptions? opts = null)
    public static GroupMembership get(String name, Output<String> id, GroupMembershipState 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:
    Group string
    The descriptor of the group being managed.
    Members List<string>

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    Mode string

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    Group string
    The descriptor of the group being managed.
    Members []string

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    Mode string

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    group String
    The descriptor of the group being managed.
    members List<String>

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    mode String

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    group string
    The descriptor of the group being managed.
    members string[]

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    mode string

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    group str
    The descriptor of the group being managed.
    members Sequence[str]

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    mode str

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    group String
    The descriptor of the group being managed.
    members List<String>

    A list of user or group descriptors that will become members of the group.

    NOTE: It's possible to define group members both within the azuredevops.GroupMembership resource via the members block and by using the azuredevops.Group resource. However it's not possible to use both methods to manage group members, since there'll be conflicts.

    mode String

    The mode how the resource manages group members.

    • mode == add: the resource will ensure that all specified members will be part of the referenced group
    • mode == overwrite: the resource will replace all existing members with the members specified within the members block

    NOTE: To clear all members from a group, specify an empty list of descriptors in the members attribute and set the mode member to overwrite.

    Import

    Not supported.

    Package Details

    Repository
    Azure DevOps pulumi/pulumi-azuredevops
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azuredevops Terraform Provider.
    azuredevops logo
    Azure DevOps v3.0.0 published on Friday, Mar 15, 2024 by Pulumi