1. Packages
  2. Gitlab Provider
  3. API Docs
  4. GroupMembership
GitLab v8.11.0 published on Friday, Apr 18, 2025 by Pulumi

gitlab.GroupMembership

Explore with Pulumi AI

The gitlab.GroupMembership resource allows to manage the lifecycle of a users group membership.

If a group should grant membership to another group use the gitlab.GroupShareGroup resource instead.

Upstream API: GitLab REST API docs

Example Usage

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

const test = new gitlab.GroupMembership("test", {
    groupId: 12345,
    userId: 1337,
    accessLevel: "guest",
    expiresAt: "2020-12-31",
});
Copy
import pulumi
import pulumi_gitlab as gitlab

test = gitlab.GroupMembership("test",
    group_id=12345,
    user_id=1337,
    access_level="guest",
    expires_at="2020-12-31")
Copy
package main

import (
	"github.com/pulumi/pulumi-gitlab/sdk/v8/go/gitlab"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := gitlab.NewGroupMembership(ctx, "test", &gitlab.GroupMembershipArgs{
			GroupId:     pulumi.Int(12345),
			UserId:      pulumi.Int(1337),
			AccessLevel: pulumi.String("guest"),
			ExpiresAt:   pulumi.String("2020-12-31"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using GitLab = Pulumi.GitLab;

return await Deployment.RunAsync(() => 
{
    var test = new GitLab.GroupMembership("test", new()
    {
        GroupId = 12345,
        UserId = 1337,
        AccessLevel = "guest",
        ExpiresAt = "2020-12-31",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gitlab.GroupMembership;
import com.pulumi.gitlab.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 test = new GroupMembership("test", GroupMembershipArgs.builder()
            .groupId(12345)
            .userId(1337)
            .accessLevel("guest")
            .expiresAt("2020-12-31")
            .build());

    }
}
Copy
resources:
  test:
    type: gitlab:GroupMembership
    properties:
      groupId: 12345
      userId: 1337
      accessLevel: guest
      expiresAt: 2020-12-31
Copy

Create GroupMembership Resource

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

Constructor syntax

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

@overload
def GroupMembership(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    access_level: Optional[str] = None,
                    group_id: Optional[int] = None,
                    user_id: Optional[int] = None,
                    expires_at: Optional[str] = None,
                    member_role_id: Optional[int] = None,
                    skip_subresources_on_destroy: Optional[bool] = None,
                    unassign_issuables_on_destroy: Optional[bool] = 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: gitlab:GroupMembership
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. GroupMembershipArgs
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. 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 This property is required. string
The unique name of the resource.
args This property is required. GroupMembershipArgs
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. GroupMembershipArgs
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. GroupMembershipArgs
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 groupMembershipResource = new GitLab.GroupMembership("groupMembershipResource", new()
{
    AccessLevel = "string",
    GroupId = 0,
    UserId = 0,
    ExpiresAt = "string",
    MemberRoleId = 0,
    SkipSubresourcesOnDestroy = false,
    UnassignIssuablesOnDestroy = false,
});
Copy
example, err := gitlab.NewGroupMembership(ctx, "groupMembershipResource", &gitlab.GroupMembershipArgs{
	AccessLevel:                pulumi.String("string"),
	GroupId:                    pulumi.Int(0),
	UserId:                     pulumi.Int(0),
	ExpiresAt:                  pulumi.String("string"),
	MemberRoleId:               pulumi.Int(0),
	SkipSubresourcesOnDestroy:  pulumi.Bool(false),
	UnassignIssuablesOnDestroy: pulumi.Bool(false),
})
Copy
var groupMembershipResource = new GroupMembership("groupMembershipResource", GroupMembershipArgs.builder()
    .accessLevel("string")
    .groupId(0)
    .userId(0)
    .expiresAt("string")
    .memberRoleId(0)
    .skipSubresourcesOnDestroy(false)
    .unassignIssuablesOnDestroy(false)
    .build());
Copy
group_membership_resource = gitlab.GroupMembership("groupMembershipResource",
    access_level="string",
    group_id=0,
    user_id=0,
    expires_at="string",
    member_role_id=0,
    skip_subresources_on_destroy=False,
    unassign_issuables_on_destroy=False)
Copy
const groupMembershipResource = new gitlab.GroupMembership("groupMembershipResource", {
    accessLevel: "string",
    groupId: 0,
    userId: 0,
    expiresAt: "string",
    memberRoleId: 0,
    skipSubresourcesOnDestroy: false,
    unassignIssuablesOnDestroy: false,
});
Copy
type: gitlab:GroupMembership
properties:
    accessLevel: string
    expiresAt: string
    groupId: 0
    memberRoleId: 0
    skipSubresourcesOnDestroy: false
    unassignIssuablesOnDestroy: false
    userId: 0
Copy

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

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

The GroupMembership resource accepts the following input properties:

AccessLevel This property is required. string
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
GroupId This property is required. int
The ID of the group.
UserId This property is required. int
The ID of the user.
ExpiresAt string
Expiration date for the group membership. Format: YYYY-MM-DD
MemberRoleId int
The ID of a custom member role. Only available for Ultimate instances.
SkipSubresourcesOnDestroy bool
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
UnassignIssuablesOnDestroy bool
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
AccessLevel This property is required. string
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
GroupId This property is required. int
The ID of the group.
UserId This property is required. int
The ID of the user.
ExpiresAt string
Expiration date for the group membership. Format: YYYY-MM-DD
MemberRoleId int
The ID of a custom member role. Only available for Ultimate instances.
SkipSubresourcesOnDestroy bool
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
UnassignIssuablesOnDestroy bool
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
accessLevel This property is required. String
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
groupId This property is required. Integer
The ID of the group.
userId This property is required. Integer
The ID of the user.
expiresAt String
Expiration date for the group membership. Format: YYYY-MM-DD
memberRoleId Integer
The ID of a custom member role. Only available for Ultimate instances.
skipSubresourcesOnDestroy Boolean
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
unassignIssuablesOnDestroy Boolean
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
accessLevel This property is required. string
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
groupId This property is required. number
The ID of the group.
userId This property is required. number
The ID of the user.
expiresAt string
Expiration date for the group membership. Format: YYYY-MM-DD
memberRoleId number
The ID of a custom member role. Only available for Ultimate instances.
skipSubresourcesOnDestroy boolean
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
unassignIssuablesOnDestroy boolean
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
access_level This property is required. str
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
group_id This property is required. int
The ID of the group.
user_id This property is required. int
The ID of the user.
expires_at str
Expiration date for the group membership. Format: YYYY-MM-DD
member_role_id int
The ID of a custom member role. Only available for Ultimate instances.
skip_subresources_on_destroy bool
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
unassign_issuables_on_destroy bool
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
accessLevel This property is required. String
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
groupId This property is required. Number
The ID of the group.
userId This property is required. Number
The ID of the user.
expiresAt String
Expiration date for the group membership. Format: YYYY-MM-DD
memberRoleId Number
The ID of a custom member role. Only available for Ultimate instances.
skipSubresourcesOnDestroy Boolean
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
unassignIssuablesOnDestroy Boolean
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.

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,
        access_level: Optional[str] = None,
        expires_at: Optional[str] = None,
        group_id: Optional[int] = None,
        member_role_id: Optional[int] = None,
        skip_subresources_on_destroy: Optional[bool] = None,
        unassign_issuables_on_destroy: Optional[bool] = None,
        user_id: Optional[int] = 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)
resources:  _:    type: gitlab:GroupMembership    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:
AccessLevel string
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
ExpiresAt string
Expiration date for the group membership. Format: YYYY-MM-DD
GroupId int
The ID of the group.
MemberRoleId int
The ID of a custom member role. Only available for Ultimate instances.
SkipSubresourcesOnDestroy bool
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
UnassignIssuablesOnDestroy bool
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
UserId int
The ID of the user.
AccessLevel string
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
ExpiresAt string
Expiration date for the group membership. Format: YYYY-MM-DD
GroupId int
The ID of the group.
MemberRoleId int
The ID of a custom member role. Only available for Ultimate instances.
SkipSubresourcesOnDestroy bool
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
UnassignIssuablesOnDestroy bool
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
UserId int
The ID of the user.
accessLevel String
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
expiresAt String
Expiration date for the group membership. Format: YYYY-MM-DD
groupId Integer
The ID of the group.
memberRoleId Integer
The ID of a custom member role. Only available for Ultimate instances.
skipSubresourcesOnDestroy Boolean
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
unassignIssuablesOnDestroy Boolean
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
userId Integer
The ID of the user.
accessLevel string
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
expiresAt string
Expiration date for the group membership. Format: YYYY-MM-DD
groupId number
The ID of the group.
memberRoleId number
The ID of a custom member role. Only available for Ultimate instances.
skipSubresourcesOnDestroy boolean
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
unassignIssuablesOnDestroy boolean
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
userId number
The ID of the user.
access_level str
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
expires_at str
Expiration date for the group membership. Format: YYYY-MM-DD
group_id int
The ID of the group.
member_role_id int
The ID of a custom member role. Only available for Ultimate instances.
skip_subresources_on_destroy bool
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
unassign_issuables_on_destroy bool
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
user_id int
The ID of the user.
accessLevel String
Access level for the member. Valid values are: no one, minimal, guest, planner, reporter, developer, maintainer, owner.
expiresAt String
Expiration date for the group membership. Format: YYYY-MM-DD
groupId Number
The ID of the group.
memberRoleId Number
The ID of a custom member role. Only available for Ultimate instances.
skipSubresourcesOnDestroy Boolean
Whether the deletion of direct memberships of the removed member in subgroups and projects should be skipped. Only used during a destroy.
unassignIssuablesOnDestroy Boolean
Whether the removed member should be unassigned from any issues or merge requests inside a given group or project. Only used during a destroy.
userId Number
The ID of the user.

Import

Starting in Terraform v1.5.0 you can use an import block to import gitlab_group_membership. For example:

terraform

import {

to = gitlab_group_membership.example

id = “see CLI command below for ID”

}

Import using the CLI is supported using the following syntax:

GitLab group membership can be imported using an id made up of group_id:user_id, e.g.

$ pulumi import gitlab:index/groupMembership:GroupMembership test "12345:1337"
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
GitLab pulumi/pulumi-gitlab
License
Apache-2.0
Notes
This Pulumi package is based on the gitlab Terraform Provider.