1. Packages
  2. Oracle Cloud Infrastructure
  3. API Docs
  4. Identity
  5. getUserGroupMemberships
Oracle Cloud Infrastructure v2.30.0 published on Monday, Apr 14, 2025 by Pulumi

oci.Identity.getUserGroupMemberships

Explore with Pulumi AI

Oracle Cloud Infrastructure v2.30.0 published on Monday, Apr 14, 2025 by Pulumi

This data source provides the list of User Group Memberships in Oracle Cloud Infrastructure Identity service.

Lists the UserGroupMembership objects in your tenancy. You must specify your tenancy’s OCID as the value for the compartment ID (see Where to Get the Tenancy’s OCID and User’s OCID). You must also then filter the list in one of these ways:

  • You can limit the results to just the memberships for a given user by specifying a userId.
  • Similarly, you can limit the results to just the memberships for a given group by specifying a groupId.
  • You can set both the userId and groupId to determine if the specified user is in the specified group. If the answer is no, the response is an empty list.
  • AlthoughuserId and groupId are not individually required, you must set one of them.

Example Usage

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

const testUserGroupMemberships = oci.Identity.getUserGroupMemberships({
    compartmentId: tenancyOcid,
    groupId: testGroup.id,
    userId: testUser.id,
});
Copy
import pulumi
import pulumi_oci as oci

test_user_group_memberships = oci.Identity.get_user_group_memberships(compartment_id=tenancy_ocid,
    group_id=test_group["id"],
    user_id=test_user["id"])
Copy
package main

import (
	"github.com/pulumi/pulumi-oci/sdk/v2/go/oci/identity"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := identity.GetUserGroupMemberships(ctx, &identity.GetUserGroupMembershipsArgs{
			CompartmentId: tenancyOcid,
			GroupId:       pulumi.StringRef(testGroup.Id),
			UserId:        pulumi.StringRef(testUser.Id),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Oci = Pulumi.Oci;

return await Deployment.RunAsync(() => 
{
    var testUserGroupMemberships = Oci.Identity.GetUserGroupMemberships.Invoke(new()
    {
        CompartmentId = tenancyOcid,
        GroupId = testGroup.Id,
        UserId = testUser.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.oci.Identity.IdentityFunctions;
import com.pulumi.oci.Identity.inputs.GetUserGroupMembershipsArgs;
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 testUserGroupMemberships = IdentityFunctions.getUserGroupMemberships(GetUserGroupMembershipsArgs.builder()
            .compartmentId(tenancyOcid)
            .groupId(testGroup.id())
            .userId(testUser.id())
            .build());

    }
}
Copy
variables:
  testUserGroupMemberships:
    fn::invoke:
      function: oci:Identity:getUserGroupMemberships
      arguments:
        compartmentId: ${tenancyOcid}
        groupId: ${testGroup.id}
        userId: ${testUser.id}
Copy

Using getUserGroupMemberships

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getUserGroupMemberships(args: GetUserGroupMembershipsArgs, opts?: InvokeOptions): Promise<GetUserGroupMembershipsResult>
function getUserGroupMembershipsOutput(args: GetUserGroupMembershipsOutputArgs, opts?: InvokeOptions): Output<GetUserGroupMembershipsResult>
Copy
def get_user_group_memberships(compartment_id: Optional[str] = None,
                               filters: Optional[Sequence[_identity.GetUserGroupMembershipsFilter]] = None,
                               group_id: Optional[str] = None,
                               user_id: Optional[str] = None,
                               opts: Optional[InvokeOptions] = None) -> GetUserGroupMembershipsResult
def get_user_group_memberships_output(compartment_id: Optional[pulumi.Input[str]] = None,
                               filters: Optional[pulumi.Input[Sequence[pulumi.Input[_identity.GetUserGroupMembershipsFilterArgs]]]] = None,
                               group_id: Optional[pulumi.Input[str]] = None,
                               user_id: Optional[pulumi.Input[str]] = None,
                               opts: Optional[InvokeOptions] = None) -> Output[GetUserGroupMembershipsResult]
Copy
func GetUserGroupMemberships(ctx *Context, args *GetUserGroupMembershipsArgs, opts ...InvokeOption) (*GetUserGroupMembershipsResult, error)
func GetUserGroupMembershipsOutput(ctx *Context, args *GetUserGroupMembershipsOutputArgs, opts ...InvokeOption) GetUserGroupMembershipsResultOutput
Copy

> Note: This function is named GetUserGroupMemberships in the Go SDK.

public static class GetUserGroupMemberships 
{
    public static Task<GetUserGroupMembershipsResult> InvokeAsync(GetUserGroupMembershipsArgs args, InvokeOptions? opts = null)
    public static Output<GetUserGroupMembershipsResult> Invoke(GetUserGroupMembershipsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetUserGroupMembershipsResult> getUserGroupMemberships(GetUserGroupMembershipsArgs args, InvokeOptions options)
public static Output<GetUserGroupMembershipsResult> getUserGroupMemberships(GetUserGroupMembershipsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: oci:Identity/getUserGroupMemberships:getUserGroupMemberships
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

CompartmentId This property is required. string
The OCID of the compartment (remember that the tenancy is simply the root compartment).
Filters Changes to this property will trigger replacement. List<GetUserGroupMembershipsFilter>
GroupId string
The OCID of the group.
UserId string
The OCID of the user.
CompartmentId This property is required. string
The OCID of the compartment (remember that the tenancy is simply the root compartment).
Filters Changes to this property will trigger replacement. []GetUserGroupMembershipsFilter
GroupId string
The OCID of the group.
UserId string
The OCID of the user.
compartmentId This property is required. String
The OCID of the compartment (remember that the tenancy is simply the root compartment).
filters Changes to this property will trigger replacement. List<GetUserGroupMembershipsFilter>
groupId String
The OCID of the group.
userId String
The OCID of the user.
compartmentId This property is required. string
The OCID of the compartment (remember that the tenancy is simply the root compartment).
filters Changes to this property will trigger replacement. GetUserGroupMembershipsFilter[]
groupId string
The OCID of the group.
userId string
The OCID of the user.
compartment_id This property is required. str
The OCID of the compartment (remember that the tenancy is simply the root compartment).
filters Changes to this property will trigger replacement. Sequence[identity.GetUserGroupMembershipsFilter]
group_id str
The OCID of the group.
user_id str
The OCID of the user.
compartmentId This property is required. String
The OCID of the compartment (remember that the tenancy is simply the root compartment).
filters Changes to this property will trigger replacement. List<Property Map>
groupId String
The OCID of the group.
userId String
The OCID of the user.

getUserGroupMemberships Result

The following output properties are available:

CompartmentId string
The OCID of the tenancy containing the user, group, and membership object.
Id string
The provider-assigned unique ID for this managed resource.
Memberships List<GetUserGroupMembershipsMembership>
The list of memberships.
Filters List<GetUserGroupMembershipsFilter>
GroupId string
The OCID of the group.
UserId string
The OCID of the user.
CompartmentId string
The OCID of the tenancy containing the user, group, and membership object.
Id string
The provider-assigned unique ID for this managed resource.
Memberships []GetUserGroupMembershipsMembership
The list of memberships.
Filters []GetUserGroupMembershipsFilter
GroupId string
The OCID of the group.
UserId string
The OCID of the user.
compartmentId String
The OCID of the tenancy containing the user, group, and membership object.
id String
The provider-assigned unique ID for this managed resource.
memberships List<GetUserGroupMembershipsMembership>
The list of memberships.
filters List<GetUserGroupMembershipsFilter>
groupId String
The OCID of the group.
userId String
The OCID of the user.
compartmentId string
The OCID of the tenancy containing the user, group, and membership object.
id string
The provider-assigned unique ID for this managed resource.
memberships GetUserGroupMembershipsMembership[]
The list of memberships.
filters GetUserGroupMembershipsFilter[]
groupId string
The OCID of the group.
userId string
The OCID of the user.
compartment_id str
The OCID of the tenancy containing the user, group, and membership object.
id str
The provider-assigned unique ID for this managed resource.
memberships Sequence[identity.GetUserGroupMembershipsMembership]
The list of memberships.
filters Sequence[identity.GetUserGroupMembershipsFilter]
group_id str
The OCID of the group.
user_id str
The OCID of the user.
compartmentId String
The OCID of the tenancy containing the user, group, and membership object.
id String
The provider-assigned unique ID for this managed resource.
memberships List<Property Map>
The list of memberships.
filters List<Property Map>
groupId String
The OCID of the group.
userId String
The OCID of the user.

Supporting Types

GetUserGroupMembershipsFilter

Name This property is required. string
Values This property is required. List<string>
Regex bool
Name This property is required. string
Values This property is required. []string
Regex bool
name This property is required. String
values This property is required. List<String>
regex Boolean
name This property is required. string
values This property is required. string[]
regex boolean
name This property is required. str
values This property is required. Sequence[str]
regex bool
name This property is required. String
values This property is required. List<String>
regex Boolean

GetUserGroupMembershipsMembership

CompartmentId This property is required. string
The OCID of the compartment (remember that the tenancy is simply the root compartment).
GroupId This property is required. string
The OCID of the group.
Id This property is required. string
The OCID of the membership.
InactiveState This property is required. string
The detailed status of INACTIVE lifecycleState.
State This property is required. string
The membership's current state.
TimeCreated This property is required. string
Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
UserId This property is required. string
The OCID of the user.
CompartmentId This property is required. string
The OCID of the compartment (remember that the tenancy is simply the root compartment).
GroupId This property is required. string
The OCID of the group.
Id This property is required. string
The OCID of the membership.
InactiveState This property is required. string
The detailed status of INACTIVE lifecycleState.
State This property is required. string
The membership's current state.
TimeCreated This property is required. string
Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
UserId This property is required. string
The OCID of the user.
compartmentId This property is required. String
The OCID of the compartment (remember that the tenancy is simply the root compartment).
groupId This property is required. String
The OCID of the group.
id This property is required. String
The OCID of the membership.
inactiveState This property is required. String
The detailed status of INACTIVE lifecycleState.
state This property is required. String
The membership's current state.
timeCreated This property is required. String
Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
userId This property is required. String
The OCID of the user.
compartmentId This property is required. string
The OCID of the compartment (remember that the tenancy is simply the root compartment).
groupId This property is required. string
The OCID of the group.
id This property is required. string
The OCID of the membership.
inactiveState This property is required. string
The detailed status of INACTIVE lifecycleState.
state This property is required. string
The membership's current state.
timeCreated This property is required. string
Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
userId This property is required. string
The OCID of the user.
compartment_id This property is required. str
The OCID of the compartment (remember that the tenancy is simply the root compartment).
group_id This property is required. str
The OCID of the group.
id This property is required. str
The OCID of the membership.
inactive_state This property is required. str
The detailed status of INACTIVE lifecycleState.
state This property is required. str
The membership's current state.
time_created This property is required. str
Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
user_id This property is required. str
The OCID of the user.
compartmentId This property is required. String
The OCID of the compartment (remember that the tenancy is simply the root compartment).
groupId This property is required. String
The OCID of the group.
id This property is required. String
The OCID of the membership.
inactiveState This property is required. String
The detailed status of INACTIVE lifecycleState.
state This property is required. String
The membership's current state.
timeCreated This property is required. String
Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
userId This property is required. String
The OCID of the user.

Package Details

Repository
oci pulumi/pulumi-oci
License
Apache-2.0
Notes
This Pulumi package is based on the oci Terraform Provider.
Oracle Cloud Infrastructure v2.30.0 published on Monday, Apr 14, 2025 by Pulumi