1. Packages
  2. Packages
  3. Mongodbatlas Provider
  4. API Docs
  5. getCloudUserProjectAssignment
Viewing docs for MongoDB Atlas v4.8.0
published on Thursday, Apr 23, 2026 by Pulumi
mongodbatlas logo
Viewing docs for MongoDB Atlas v4.8.0
published on Thursday, Apr 23, 2026 by Pulumi

    mongodbatlas.CloudUserProjectAssignment provides a Cloud User Project Assignment data source. The data source lets you retrieve a user assigned to a project.

    NOTE: Users with pending invitations created using the deprecated mongodbatlas.ProjectInvitation resource or via the deprecated Invite One MongoDB Cloud User to One Project endpoint are not returned with this resource. See MongoDB Atlas API for details. To manage such users with this resource, refer to our Project Invitation to Cloud User Project Assignment Migration Guide.

    Example Usage

    S

    import * as pulumi from "@pulumi/pulumi";
    import * as mongodbatlas from "@pulumi/mongodbatlas";
    
    const example = new mongodbatlas.CloudUserProjectAssignment("example", {
        projectId: projectId,
        username: userEmail,
        roles: [
            "GROUP_OWNER",
            "GROUP_DATA_ACCESS_ADMIN",
        ],
    });
    const exampleUsername = example.username.apply(username => mongodbatlas.getCloudUserProjectAssignmentOutput({
        projectId: projectId,
        username: username,
    }));
    const exampleUserId = example.userId.apply(userId => mongodbatlas.getCloudUserProjectAssignmentOutput({
        projectId: projectId,
        userId: userId,
    }));
    
    import pulumi
    import pulumi_mongodbatlas as mongodbatlas
    
    example = mongodbatlas.CloudUserProjectAssignment("example",
        project_id=project_id,
        username=user_email,
        roles=[
            "GROUP_OWNER",
            "GROUP_DATA_ACCESS_ADMIN",
        ])
    example_username = example.username.apply(lambda username: mongodbatlas.get_cloud_user_project_assignment_output(project_id=project_id,
        username=username))
    example_user_id = example.user_id.apply(lambda user_id: mongodbatlas.get_cloud_user_project_assignment_output(project_id=project_id,
        user_id=user_id))
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-mongodbatlas/sdk/v4/go/mongodbatlas"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := mongodbatlas.NewCloudUserProjectAssignment(ctx, "example", &mongodbatlas.CloudUserProjectAssignmentArgs{
    			ProjectId: pulumi.Any(projectId),
    			Username:  pulumi.Any(userEmail),
    			Roles: pulumi.StringArray{
    				pulumi.String("GROUP_OWNER"),
    				pulumi.String("GROUP_DATA_ACCESS_ADMIN"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_ = example.Username.ApplyT(func(username string) (mongodbatlas.GetCloudUserProjectAssignmentResult, error) {
    			return mongodbatlas.GetCloudUserProjectAssignmentResult(interface{}(mongodbatlas.GetCloudUserProjectAssignment(ctx, &mongodbatlas.LookupCloudUserProjectAssignmentArgs{
    				ProjectId: projectId,
    				Username:  pulumi.StringRef(pulumi.StringRef(username)),
    			}, nil))), nil
    		}).(mongodbatlas.GetCloudUserProjectAssignmentResultOutput)
    		_ = example.UserId.ApplyT(func(userId string) (mongodbatlas.GetCloudUserProjectAssignmentResult, error) {
    			return mongodbatlas.GetCloudUserProjectAssignmentResult(interface{}(mongodbatlas.GetCloudUserProjectAssignment(ctx, &mongodbatlas.LookupCloudUserProjectAssignmentArgs{
    				ProjectId: projectId,
    				UserId:    pulumi.StringRef(pulumi.StringRef(userId)),
    			}, nil))), nil
    		}).(mongodbatlas.GetCloudUserProjectAssignmentResultOutput)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Mongodbatlas = Pulumi.Mongodbatlas;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Mongodbatlas.Index.CloudUserProjectAssignment("example", new()
        {
            ProjectId = projectId,
            Username = userEmail,
            Roles = new[]
            {
                "GROUP_OWNER",
                "GROUP_DATA_ACCESS_ADMIN",
            },
        });
    
        var exampleUsername = Mongodbatlas.Index.GetCloudUserProjectAssignment.Invoke(new()
        {
            ProjectId = projectId,
            Username = example.Username,
        });
    
        var exampleUserId = Mongodbatlas.Index.GetCloudUserProjectAssignment.Invoke(new()
        {
            ProjectId = projectId,
            UserId = example.UserId,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.mongodbatlas.CloudUserProjectAssignment;
    import com.pulumi.mongodbatlas.CloudUserProjectAssignmentArgs;
    import com.pulumi.mongodbatlas.MongodbatlasFunctions;
    import com.pulumi.mongodbatlas.inputs.GetCloudUserProjectAssignmentArgs;
    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 example = new CloudUserProjectAssignment("example", CloudUserProjectAssignmentArgs.builder()
                .projectId(projectId)
                .username(userEmail)
                .roles(            
                    "GROUP_OWNER",
                    "GROUP_DATA_ACCESS_ADMIN")
                .build());
    
            final var exampleUsername = example.username().applyValue(_username -> MongodbatlasFunctions.getCloudUserProjectAssignment(GetCloudUserProjectAssignmentArgs.builder()
                .projectId(projectId)
                .username(_username)
                .build()));
    
            final var exampleUserId = example.userId().applyValue(_userId -> MongodbatlasFunctions.getCloudUserProjectAssignment(GetCloudUserProjectAssignmentArgs.builder()
                .projectId(projectId)
                .userId(_userId)
                .build()));
    
        }
    }
    
    resources:
      example:
        type: mongodbatlas:CloudUserProjectAssignment
        properties:
          projectId: ${projectId}
          username: ${userEmail}
          roles:
            - GROUP_OWNER
            - GROUP_DATA_ACCESS_ADMIN
    variables:
      exampleUsername:
        fn::invoke:
          function: mongodbatlas:getCloudUserProjectAssignment
          arguments:
            projectId: ${projectId}
            username: ${example.username}
      exampleUserId:
        fn::invoke:
          function: mongodbatlas:getCloudUserProjectAssignment
          arguments:
            projectId: ${projectId}
            userId: ${example.userId}
    

    Using getCloudUserProjectAssignment

    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 getCloudUserProjectAssignment(args: GetCloudUserProjectAssignmentArgs, opts?: InvokeOptions): Promise<GetCloudUserProjectAssignmentResult>
    function getCloudUserProjectAssignmentOutput(args: GetCloudUserProjectAssignmentOutputArgs, opts?: InvokeOptions): Output<GetCloudUserProjectAssignmentResult>
    def get_cloud_user_project_assignment(project_id: Optional[str] = None,
                                          user_id: Optional[str] = None,
                                          username: Optional[str] = None,
                                          opts: Optional[InvokeOptions] = None) -> GetCloudUserProjectAssignmentResult
    def get_cloud_user_project_assignment_output(project_id: Optional[pulumi.Input[str]] = None,
                                          user_id: Optional[pulumi.Input[str]] = None,
                                          username: Optional[pulumi.Input[str]] = None,
                                          opts: Optional[InvokeOptions] = None) -> Output[GetCloudUserProjectAssignmentResult]
    func LookupCloudUserProjectAssignment(ctx *Context, args *LookupCloudUserProjectAssignmentArgs, opts ...InvokeOption) (*LookupCloudUserProjectAssignmentResult, error)
    func LookupCloudUserProjectAssignmentOutput(ctx *Context, args *LookupCloudUserProjectAssignmentOutputArgs, opts ...InvokeOption) LookupCloudUserProjectAssignmentResultOutput

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

    public static class GetCloudUserProjectAssignment 
    {
        public static Task<GetCloudUserProjectAssignmentResult> InvokeAsync(GetCloudUserProjectAssignmentArgs args, InvokeOptions? opts = null)
        public static Output<GetCloudUserProjectAssignmentResult> Invoke(GetCloudUserProjectAssignmentInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetCloudUserProjectAssignmentResult> getCloudUserProjectAssignment(GetCloudUserProjectAssignmentArgs args, InvokeOptions options)
    public static Output<GetCloudUserProjectAssignmentResult> getCloudUserProjectAssignment(GetCloudUserProjectAssignmentArgs args, InvokeOptions options)
    
    fn::invoke:
      function: mongodbatlas:index/getCloudUserProjectAssignment:getCloudUserProjectAssignment
      arguments:
        # arguments dictionary

    The following arguments are supported:

    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    UserId string
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    Username string
    Email address that represents the username of the MongoDB Cloud user.
    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    UserId string
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    Username string
    Email address that represents the username of the MongoDB Cloud user.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    userId String
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    username String
    Email address that represents the username of the MongoDB Cloud user.
    projectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    userId string
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    username string
    Email address that represents the username of the MongoDB Cloud user.
    project_id str
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    user_id str
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    username str
    Email address that represents the username of the MongoDB Cloud user.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    userId String
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    username String
    Email address that represents the username of the MongoDB Cloud user.

    getCloudUserProjectAssignment Result

    The following output properties are available:

    Country string
    Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format.
    CreatedAt string
    Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC.
    FirstName string
    First or given name that belongs to the MongoDB Cloud user.
    Id string
    The provider-assigned unique ID for this managed resource.
    InvitationCreatedAt string
    Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    InvitationExpiresAt string
    Date and time when the invitation from MongoDB Cloud expires. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    InviterUsername string
    Username of the MongoDB Cloud user who sent the invitation to join the organization.
    LastAuth string
    Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC.
    LastName string
    Last name, family name, or surname that belongs to the MongoDB Cloud user.
    MobileNumber string
    Mobile phone number that belongs to the MongoDB Cloud user.
    OrgMembershipStatus string
    String enum that indicates whether the MongoDB Cloud user has a pending invitation to join the organization or they are already active in the organization.
    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    Roles List<string>
    One or more project-level roles to assign the MongoDB Cloud user.
    UserId string
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    Username string
    Email address that represents the username of the MongoDB Cloud user.
    Country string
    Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format.
    CreatedAt string
    Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC.
    FirstName string
    First or given name that belongs to the MongoDB Cloud user.
    Id string
    The provider-assigned unique ID for this managed resource.
    InvitationCreatedAt string
    Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    InvitationExpiresAt string
    Date and time when the invitation from MongoDB Cloud expires. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    InviterUsername string
    Username of the MongoDB Cloud user who sent the invitation to join the organization.
    LastAuth string
    Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC.
    LastName string
    Last name, family name, or surname that belongs to the MongoDB Cloud user.
    MobileNumber string
    Mobile phone number that belongs to the MongoDB Cloud user.
    OrgMembershipStatus string
    String enum that indicates whether the MongoDB Cloud user has a pending invitation to join the organization or they are already active in the organization.
    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    Roles []string
    One or more project-level roles to assign the MongoDB Cloud user.
    UserId string
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    Username string
    Email address that represents the username of the MongoDB Cloud user.
    country String
    Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format.
    createdAt String
    Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC.
    firstName String
    First or given name that belongs to the MongoDB Cloud user.
    id String
    The provider-assigned unique ID for this managed resource.
    invitationCreatedAt String
    Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    invitationExpiresAt String
    Date and time when the invitation from MongoDB Cloud expires. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    inviterUsername String
    Username of the MongoDB Cloud user who sent the invitation to join the organization.
    lastAuth String
    Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC.
    lastName String
    Last name, family name, or surname that belongs to the MongoDB Cloud user.
    mobileNumber String
    Mobile phone number that belongs to the MongoDB Cloud user.
    orgMembershipStatus String
    String enum that indicates whether the MongoDB Cloud user has a pending invitation to join the organization or they are already active in the organization.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    roles List<String>
    One or more project-level roles to assign the MongoDB Cloud user.
    userId String
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    username String
    Email address that represents the username of the MongoDB Cloud user.
    country string
    Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format.
    createdAt string
    Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC.
    firstName string
    First or given name that belongs to the MongoDB Cloud user.
    id string
    The provider-assigned unique ID for this managed resource.
    invitationCreatedAt string
    Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    invitationExpiresAt string
    Date and time when the invitation from MongoDB Cloud expires. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    inviterUsername string
    Username of the MongoDB Cloud user who sent the invitation to join the organization.
    lastAuth string
    Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC.
    lastName string
    Last name, family name, or surname that belongs to the MongoDB Cloud user.
    mobileNumber string
    Mobile phone number that belongs to the MongoDB Cloud user.
    orgMembershipStatus string
    String enum that indicates whether the MongoDB Cloud user has a pending invitation to join the organization or they are already active in the organization.
    projectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    roles string[]
    One or more project-level roles to assign the MongoDB Cloud user.
    userId string
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    username string
    Email address that represents the username of the MongoDB Cloud user.
    country str
    Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format.
    created_at str
    Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC.
    first_name str
    First or given name that belongs to the MongoDB Cloud user.
    id str
    The provider-assigned unique ID for this managed resource.
    invitation_created_at str
    Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    invitation_expires_at str
    Date and time when the invitation from MongoDB Cloud expires. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    inviter_username str
    Username of the MongoDB Cloud user who sent the invitation to join the organization.
    last_auth str
    Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC.
    last_name str
    Last name, family name, or surname that belongs to the MongoDB Cloud user.
    mobile_number str
    Mobile phone number that belongs to the MongoDB Cloud user.
    org_membership_status str
    String enum that indicates whether the MongoDB Cloud user has a pending invitation to join the organization or they are already active in the organization.
    project_id str
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    roles Sequence[str]
    One or more project-level roles to assign the MongoDB Cloud user.
    user_id str
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    username str
    Email address that represents the username of the MongoDB Cloud user.
    country String
    Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format.
    createdAt String
    Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC.
    firstName String
    First or given name that belongs to the MongoDB Cloud user.
    id String
    The provider-assigned unique ID for this managed resource.
    invitationCreatedAt String
    Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    invitationExpiresAt String
    Date and time when the invitation from MongoDB Cloud expires. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
    inviterUsername String
    Username of the MongoDB Cloud user who sent the invitation to join the organization.
    lastAuth String
    Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC.
    lastName String
    Last name, family name, or surname that belongs to the MongoDB Cloud user.
    mobileNumber String
    Mobile phone number that belongs to the MongoDB Cloud user.
    orgMembershipStatus String
    String enum that indicates whether the MongoDB Cloud user has a pending invitation to join the organization or they are already active in the organization.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    roles List<String>
    One or more project-level roles to assign the MongoDB Cloud user.
    userId String
    Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
    username String
    Email address that represents the username of the MongoDB Cloud user.

    Package Details

    Repository
    MongoDB Atlas pulumi/pulumi-mongodbatlas
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the mongodbatlas Terraform Provider.
    mongodbatlas logo
    Viewing docs for MongoDB Atlas v4.8.0
    published on Thursday, Apr 23, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.