1. Registry
  2. Packages
  3. Mongodbatlas Provider
  4. API Docs
  5. getProjectServiceAccounts
Viewing docs for MongoDB Atlas v4.18.1
published on Tuesday, Oct 27, 2026 by Pulumi
mongodbatlas logo mongodbatlas logo
Viewing docs for MongoDB Atlas v4.18.1
published on Tuesday, Oct 27, 2026 by Pulumi

    mongodbatlas.getProjectServiceAccounts returns all Service Accounts for the specified Project.

    IMPORTANT WARNING: Managing Service Accounts with Terraform exposes sensitive organizational secrets in Terraform’s state. We suggest following Terraform’s best practices.

    Example Usage

    S

    import * as pulumi from "@pulumi/pulumi";
    import * as mongodbatlas from "@pulumi/mongodbatlas";
    
    // Read the Project Service Account and the project's Service Accounts back from Atlas.
    const _this = mongodbatlas.getProjectServiceAccount({
        projectId: projectId,
        clientId: thisMongodbatlasProjectServiceAccount.clientId,
    });
    const thisGetProjectServiceAccounts = mongodbatlas.getProjectServiceAccounts({
        projectId: projectId,
    });
    export const serviceAccountClientId = thisMongodbatlasProjectServiceAccount.clientId;
    export const serviceAccountName = _this.then(_this => _this.name);
    export const serviceAccountsResults = thisGetProjectServiceAccounts.then(thisGetProjectServiceAccounts => thisGetProjectServiceAccounts.results);
    
    import pulumi
    import pulumi_mongodbatlas as mongodbatlas
    
    # Read the Project Service Account and the project's Service Accounts back from Atlas.
    this = mongodbatlas.get_project_service_account(project_id=project_id,
        client_id=this_mongodbatlas_project_service_account["clientId"])
    this_get_project_service_accounts = mongodbatlas.get_project_service_accounts(project_id=project_id)
    pulumi.export("serviceAccountClientId", this_mongodbatlas_project_service_account["clientId"])
    pulumi.export("serviceAccountName", this.name)
    pulumi.export("serviceAccountsResults", this_get_project_service_accounts.results)
    
    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 {
    		// Read the Project Service Account and the project's Service Accounts back from Atlas.
    		this, err := mongodbatlas.GetProjectServiceAccount(ctx, &mongodbatlas.LookupProjectServiceAccountArgs{
    			ProjectId: projectId,
    			ClientId:  thisMongodbatlasProjectServiceAccount.ClientId,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		thisGetProjectServiceAccounts, err := mongodbatlas.GetProjectServiceAccounts(ctx, &mongodbatlas.LookupProjectServiceAccountsArgs{
    			ProjectId: projectId,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("serviceAccountClientId", pulumi.Any(thisMongodbatlasProjectServiceAccount.ClientId))
    		ctx.Export("serviceAccountName", this.Name)
    		ctx.Export("serviceAccountsResults", thisGetProjectServiceAccounts.Results)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Mongodbatlas = Pulumi.Mongodbatlas;
    
    return await Deployment.RunAsync(() => 
    {
        // Read the Project Service Account and the project's Service Accounts back from Atlas.
        var @this = Mongodbatlas.GetProjectServiceAccount.Invoke(new()
        {
            ProjectId = projectId,
            ClientId = thisMongodbatlasProjectServiceAccount.ClientId,
        });
    
        var thisGetProjectServiceAccounts = Mongodbatlas.GetProjectServiceAccounts.Invoke(new()
        {
            ProjectId = projectId,
        });
    
        return new Dictionary<string, object?>
        {
            ["serviceAccountClientId"] = thisMongodbatlasProjectServiceAccount.ClientId,
            ["serviceAccountName"] = @this.Apply(@this => @this.Apply(getProjectServiceAccountResult => getProjectServiceAccountResult.Name)),
            ["serviceAccountsResults"] = thisGetProjectServiceAccounts.Apply(getProjectServiceAccountsResult => getProjectServiceAccountsResult.Results),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.mongodbatlas.MongodbatlasFunctions;
    import com.pulumi.mongodbatlas.inputs.GetProjectServiceAccountArgs;
    import com.pulumi.mongodbatlas.inputs.GetProjectServiceAccountsArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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) {
            // Read the Project Service Account and the project's Service Accounts back from Atlas.
            final var this = MongodbatlasFunctions.getProjectServiceAccount(GetProjectServiceAccountArgs.builder()
                .projectId(projectId)
                .clientId(thisMongodbatlasProjectServiceAccount.get("clientId"))
                .build());
    
            final var thisGetProjectServiceAccounts = MongodbatlasFunctions.getProjectServiceAccounts(GetProjectServiceAccountsArgs.builder()
                .projectId(projectId)
                .build());
    
            ctx.export("serviceAccountClientId", thisMongodbatlasProjectServiceAccount.get("clientId"));
            ctx.export("serviceAccountName", this_.name());
            ctx.export("serviceAccountsResults", thisGetProjectServiceAccounts.results());
        }
    }
    
    variables:
      # Read the Project Service Account and the project's Service Accounts back from Atlas.
      this:
        fn::invoke:
          function: mongodbatlas:getProjectServiceAccount
          arguments:
            projectId: ${projectId}
            clientId: ${thisMongodbatlasProjectServiceAccount.clientId}
      thisGetProjectServiceAccounts:
        fn::invoke:
          function: mongodbatlas:getProjectServiceAccounts
          arguments:
            projectId: ${projectId}
    outputs:
      serviceAccountClientId: ${thisMongodbatlasProjectServiceAccount.clientId}
      serviceAccountName: ${this.name}
      serviceAccountsResults: ${thisGetProjectServiceAccounts.results}
    
    terraform {
      required_providers {
        mongodbatlas = {
          source = "pulumi/mongodbatlas"
        }
      }
    }
    
    data "mongodbatlas_project_service_account" "this" {
      project_id = projectId
      client_id  = thisMongodbatlasProjectServiceAccount.clientId
    }
    data "mongodbatlas_project_service_accounts" "thisGetProjectServiceAccounts" {
      project_id = projectId
    }
    
    # Read the Project Service Account and the project's Service Accounts back from Atlas.
    output "serviceAccountClientId" {
      value = thisMongodbatlasProjectServiceAccount.clientId
    }
    output "serviceAccountName" {
      value = data.mongodbatlas_project_service_account.this.name
    }
    output "serviceAccountsResults" {
      value = data.mongodbatlas_project_service_accounts.thisGetProjectServiceAccounts.results
    }
    

    Using getProjectServiceAccounts

    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 getProjectServiceAccounts(args: GetProjectServiceAccountsArgs, opts?: InvokeOptions): Promise<GetProjectServiceAccountsResult>
    function getProjectServiceAccountsOutput(args: GetProjectServiceAccountsOutputArgs, opts?: InvokeOutputOptions): Output<GetProjectServiceAccountsResult>
    def get_project_service_accounts(include_system_managed: Optional[bool] = None,
                                     project_id: Optional[str] = None,
                                     opts: Optional[InvokeOptions] = None) -> GetProjectServiceAccountsResult
    def get_project_service_accounts_output(include_system_managed: pulumi.Input[Optional[bool]] = None,
                                     project_id: pulumi.Input[Optional[str]] = None,
                                     opts: Optional[InvokeOutputOptions] = None) -> Output[GetProjectServiceAccountsResult]
    func LookupProjectServiceAccounts(ctx *Context, args *LookupProjectServiceAccountsArgs, opts ...InvokeOption) (*LookupProjectServiceAccountsResult, error)
    func LookupProjectServiceAccountsOutput(ctx *Context, args *LookupProjectServiceAccountsOutputArgs, opts ...InvokeOption) LookupProjectServiceAccountsResultOutput

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

    public static class GetProjectServiceAccounts 
    {
        public static Task<GetProjectServiceAccountsResult> InvokeAsync(GetProjectServiceAccountsArgs args, InvokeOptions? opts = null)
        public static Output<GetProjectServiceAccountsResult> Invoke(GetProjectServiceAccountsInvokeArgs args, InvokeOptions? opts = null)
        public static Output<GetProjectServiceAccountsResult> Invoke(GetProjectServiceAccountsInvokeArgs args, InvokeOutputOptions opts)
    }
    public static CompletableFuture<GetProjectServiceAccountsResult> getProjectServiceAccounts(GetProjectServiceAccountsArgs args, InvokeOptions options)
    public static Output<GetProjectServiceAccountsResult> getProjectServiceAccounts(GetProjectServiceAccountsArgs args, InvokeOptions options)
    public static Output<GetProjectServiceAccountsResult> getProjectServiceAccounts(GetProjectServiceAccountsArgs args, InvokeOutputOptions options)
    
    fn::invoke:
      function: mongodbatlas:index/getProjectServiceAccounts:getProjectServiceAccounts
      arguments:
        # arguments dictionary
    data "mongodbatlas_get_project_service_accounts" "name" {
        # arguments
    }

    The following arguments are supported:

    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    IncludeSystemManaged bool
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    IncludeSystemManaged bool
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    project_id string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    include_system_managed bool
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    includeSystemManaged Boolean
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    projectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    includeSystemManaged boolean
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    project_id str
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    include_system_managed bool
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    includeSystemManaged Boolean
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.

    getProjectServiceAccounts Result

    The following output properties are available:

    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    Results List<GetProjectServiceAccountsResult>
    List of returned documents that MongoDB Cloud provides when completing this request.
    IncludeSystemManaged bool
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    Results []GetProjectServiceAccountsResult
    List of returned documents that MongoDB Cloud provides when completing this request.
    IncludeSystemManaged bool
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    project_id string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results list(object)
    List of returned documents that MongoDB Cloud provides when completing this request.
    include_system_managed bool
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results List<GetProjectServiceAccountsResult>
    List of returned documents that MongoDB Cloud provides when completing this request.
    includeSystemManaged Boolean
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    projectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results GetProjectServiceAccountsResult[]
    List of returned documents that MongoDB Cloud provides when completing this request.
    includeSystemManaged boolean
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    project_id str
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results Sequence[GetProjectServiceAccountsResult]
    List of returned documents that MongoDB Cloud provides when completing this request.
    include_system_managed bool
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results List<Property Map>
    List of returned documents that MongoDB Cloud provides when completing this request.
    includeSystemManaged Boolean
    Flag that indicates whether system-managed Service Accounts (such as those used for MCP ingress/egress integrations) are included in the response. When false, only user-managed Service Accounts are returned.

    Supporting Types

    GetProjectServiceAccountsResult

    ClientId string
    The Client ID of the Service Account.
    CreatedAt string
    The date that the Service Account was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    Description string
    Human readable description for the Service Account.
    Name string
    Human-readable name for the Service Account.
    Roles List<string>
    A list of Project roles associated with the Service Account.
    Secrets List<GetProjectServiceAccountsResultSecret>
    A list of secrets associated with the specified Service Account.
    SystemManaged bool
    Indicates whether the Service Account is system managed.
    ClientId string
    The Client ID of the Service Account.
    CreatedAt string
    The date that the Service Account was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    Description string
    Human readable description for the Service Account.
    Name string
    Human-readable name for the Service Account.
    Roles []string
    A list of Project roles associated with the Service Account.
    Secrets []GetProjectServiceAccountsResultSecret
    A list of secrets associated with the specified Service Account.
    SystemManaged bool
    Indicates whether the Service Account is system managed.
    client_id string
    The Client ID of the Service Account.
    created_at string
    The date that the Service Account was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    description string
    Human readable description for the Service Account.
    name string
    Human-readable name for the Service Account.
    roles list(string)
    A list of Project roles associated with the Service Account.
    secrets list(object)
    A list of secrets associated with the specified Service Account.
    system_managed bool
    Indicates whether the Service Account is system managed.
    clientId String
    The Client ID of the Service Account.
    createdAt String
    The date that the Service Account was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    description String
    Human readable description for the Service Account.
    name String
    Human-readable name for the Service Account.
    roles List<String>
    A list of Project roles associated with the Service Account.
    secrets List<GetProjectServiceAccountsResultSecret>
    A list of secrets associated with the specified Service Account.
    systemManaged Boolean
    Indicates whether the Service Account is system managed.
    clientId string
    The Client ID of the Service Account.
    createdAt string
    The date that the Service Account was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    description string
    Human readable description for the Service Account.
    name string
    Human-readable name for the Service Account.
    roles string[]
    A list of Project roles associated with the Service Account.
    secrets GetProjectServiceAccountsResultSecret[]
    A list of secrets associated with the specified Service Account.
    systemManaged boolean
    Indicates whether the Service Account is system managed.
    client_id str
    The Client ID of the Service Account.
    created_at str
    The date that the Service Account was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    description str
    Human readable description for the Service Account.
    name str
    Human-readable name for the Service Account.
    roles Sequence[str]
    A list of Project roles associated with the Service Account.
    secrets Sequence[GetProjectServiceAccountsResultSecret]
    A list of secrets associated with the specified Service Account.
    system_managed bool
    Indicates whether the Service Account is system managed.
    clientId String
    The Client ID of the Service Account.
    createdAt String
    The date that the Service Account was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    description String
    Human readable description for the Service Account.
    name String
    Human-readable name for the Service Account.
    roles List<String>
    A list of Project roles associated with the Service Account.
    secrets List<Property Map>
    A list of secrets associated with the specified Service Account.
    systemManaged Boolean
    Indicates whether the Service Account is system managed.

    GetProjectServiceAccountsResultSecret

    CreatedAt string
    The date that the secret was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    ExpiresAt string
    The date for the expiration of the secret. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    LastUsedAt string
    The last time the secret was used. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    MaskedSecretValue string
    The masked Service Account secret.
    SecretId string
    Unique 24-hexadecimal digit string that identifies the secret.
    CreatedAt string
    The date that the secret was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    ExpiresAt string
    The date for the expiration of the secret. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    LastUsedAt string
    The last time the secret was used. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    MaskedSecretValue string
    The masked Service Account secret.
    SecretId string
    Unique 24-hexadecimal digit string that identifies the secret.
    created_at string
    The date that the secret was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    expires_at string
    The date for the expiration of the secret. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    last_used_at string
    The last time the secret was used. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    masked_secret_value string
    The masked Service Account secret.
    secret_id string
    Unique 24-hexadecimal digit string that identifies the secret.
    createdAt String
    The date that the secret was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    expiresAt String
    The date for the expiration of the secret. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    lastUsedAt String
    The last time the secret was used. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    maskedSecretValue String
    The masked Service Account secret.
    secretId String
    Unique 24-hexadecimal digit string that identifies the secret.
    createdAt string
    The date that the secret was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    expiresAt string
    The date for the expiration of the secret. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    lastUsedAt string
    The last time the secret was used. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    maskedSecretValue string
    The masked Service Account secret.
    secretId string
    Unique 24-hexadecimal digit string that identifies the secret.
    created_at str
    The date that the secret was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    expires_at str
    The date for the expiration of the secret. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    last_used_at str
    The last time the secret was used. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    masked_secret_value str
    The masked Service Account secret.
    secret_id str
    Unique 24-hexadecimal digit string that identifies the secret.
    createdAt String
    The date that the secret was created on. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    expiresAt String
    The date for the expiration of the secret. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    lastUsedAt String
    The last time the secret was used. This parameter expresses its value in the ISO 8601 timestamp format in UTC.
    maskedSecretValue String
    The masked Service Account secret.
    secretId String
    Unique 24-hexadecimal digit string that identifies the secret.

    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 mongodbatlas logo
    Viewing docs for MongoDB Atlas v4.18.1
    published on Tuesday, Oct 27, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial