oci.Identity.getUserGroupMemberships
Explore with Pulumi AI
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 userIdandgroupIdto determine if the specified user is in the specified group. If the answer is no, the response is an empty list.
- AlthoughuserIdandgroupIdare 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,
});
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"])
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
	})
}
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,
    });
});
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());
    }
}
variables:
  testUserGroupMemberships:
    fn::invoke:
      function: oci:Identity:getUserGroupMemberships
      arguments:
        compartmentId: ${tenancyOcid}
        groupId: ${testGroup.id}
        userId: ${testUser.id}
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>def get_user_group_memberships(compartment_id: Optional[str] = None,
                               filters: Optional[Sequence[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[GetUserGroupMembershipsFilterArgs]]]] = None,
                               group_id: Optional[pulumi.Input[str]] = None,
                               user_id: Optional[pulumi.Input[str]] = None,
                               opts: Optional[InvokeOptions] = None) -> Output[GetUserGroupMembershipsResult]func GetUserGroupMemberships(ctx *Context, args *GetUserGroupMembershipsArgs, opts ...InvokeOption) (*GetUserGroupMembershipsResult, error)
func GetUserGroupMembershipsOutput(ctx *Context, args *GetUserGroupMembershipsOutputArgs, opts ...InvokeOption) GetUserGroupMembershipsResultOutput> 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)
}public static CompletableFuture<GetUserGroupMembershipsResult> getUserGroupMemberships(GetUserGroupMembershipsArgs args, InvokeOptions options)
public static Output<GetUserGroupMembershipsResult> getUserGroupMemberships(GetUserGroupMembershipsArgs args, InvokeOptions options)
fn::invoke:
  function: oci:Identity/getUserGroupMemberships:getUserGroupMemberships
  arguments:
    # arguments dictionaryThe following arguments are supported:
- CompartmentId string
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- Filters
List<GetUser Group Memberships Filter> 
- GroupId string
- The OCID of the group.
- UserId string
- The OCID of the user.
- CompartmentId string
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- Filters
[]GetUser Group Memberships Filter 
- GroupId string
- The OCID of the group.
- UserId string
- The OCID of the user.
- compartmentId String
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- filters
List<GetUser Group Memberships Filter> 
- groupId String
- The OCID of the group.
- userId String
- The OCID of the user.
- compartmentId string
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- filters
GetUser Group Memberships Filter[] 
- groupId string
- The OCID of the group.
- userId string
- The OCID of the user.
- compartment_id str
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- filters
Sequence[GetUser Group Memberships Filter] 
- group_id str
- The OCID of the group.
- user_id str
- The OCID of the user.
- compartmentId String
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- filters 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<GetUser Group Memberships Membership> 
- The list of memberships.
- Filters
List<GetUser Group Memberships Filter> 
- 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
[]GetUser Group Memberships Membership 
- The list of memberships.
- Filters
[]GetUser Group Memberships Filter 
- 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<GetUser Group Memberships Membership> 
- The list of memberships.
- filters
List<GetUser Group Memberships Filter> 
- 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
GetUser Group Memberships Membership[] 
- The list of memberships.
- filters
GetUser Group Memberships Filter[] 
- 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[GetUser Group Memberships Membership] 
- The list of memberships.
- filters
Sequence[GetUser Group Memberships Filter] 
- 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    
GetUserGroupMembershipsMembership    
- CompartmentId string
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- GroupId string
- The OCID of the group.
- Id string
- The OCID of the membership.
- InactiveState string
- The detailed status of INACTIVE lifecycleState.
- State string
- The membership's current state.
- TimeCreated string
- Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- UserId string
- The OCID of the user.
- CompartmentId string
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- GroupId string
- The OCID of the group.
- Id string
- The OCID of the membership.
- InactiveState string
- The detailed status of INACTIVE lifecycleState.
- State string
- The membership's current state.
- TimeCreated string
- Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- UserId string
- The OCID of the user.
- compartmentId String
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- groupId String
- The OCID of the group.
- id String
- The OCID of the membership.
- inactiveState String
- The detailed status of INACTIVE lifecycleState.
- state String
- The membership's current state.
- timeCreated String
- Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- userId String
- The OCID of the user.
- compartmentId string
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- groupId string
- The OCID of the group.
- id string
- The OCID of the membership.
- inactiveState string
- The detailed status of INACTIVE lifecycleState.
- state string
- The membership's current state.
- timeCreated string
- Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- userId string
- The OCID of the user.
- compartment_id str
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- group_id str
- The OCID of the group.
- id str
- The OCID of the membership.
- inactive_state str
- The detailed status of INACTIVE lifecycleState.
- state str
- The membership's current state.
- time_created str
- Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- user_id str
- The OCID of the user.
- compartmentId String
- The OCID of the compartment (remember that the tenancy is simply the root compartment).
- groupId String
- The OCID of the group.
- id String
- The OCID of the membership.
- inactiveState String
- The detailed status of INACTIVE lifecycleState.
- state String
- The membership's current state.
- timeCreated String
- Date and time the membership was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
- userId 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 ociTerraform Provider.