1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. mongodb
  5. getAccounts
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.mongodb.getAccounts

Explore with Pulumi AI

Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

This data source provides the Mongodb Accounts of the current Alibaba Cloud user.

NOTE: Available in v1.148.0+.

Example Usage

Basic Usage

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

const example = alicloud.mongodb.getAccounts({
    instanceId: "example_value",
    accountName: "root",
});
export const mongodbAccountId1 = example.then(example => example.accounts?.[0]?.id);
Copy
import pulumi
import pulumi_alicloud as alicloud

example = alicloud.mongodb.get_accounts(instance_id="example_value",
    account_name="root")
pulumi.export("mongodbAccountId1", example.accounts[0].id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/mongodb"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := mongodb.GetAccounts(ctx, &mongodb.GetAccountsArgs{
			InstanceId:  "example_value",
			AccountName: pulumi.StringRef("root"),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("mongodbAccountId1", example.Accounts[0].Id)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var example = AliCloud.MongoDB.GetAccounts.Invoke(new()
    {
        InstanceId = "example_value",
        AccountName = "root",
    });

    return new Dictionary<string, object?>
    {
        ["mongodbAccountId1"] = example.Apply(getAccountsResult => getAccountsResult.Accounts[0]?.Id),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.mongodb.MongodbFunctions;
import com.pulumi.alicloud.mongodb.inputs.GetAccountsArgs;
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 example = MongodbFunctions.getAccounts(GetAccountsArgs.builder()
            .instanceId("example_value")
            .accountName("root")
            .build());

        ctx.export("mongodbAccountId1", example.applyValue(getAccountsResult -> getAccountsResult.accounts()[0].id()));
    }
}
Copy
variables:
  example:
    fn::invoke:
      function: alicloud:mongodb:getAccounts
      arguments:
        instanceId: example_value
        accountName: root
outputs:
  mongodbAccountId1: ${example.accounts[0].id}
Copy

Using getAccounts

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 getAccounts(args: GetAccountsArgs, opts?: InvokeOptions): Promise<GetAccountsResult>
function getAccountsOutput(args: GetAccountsOutputArgs, opts?: InvokeOptions): Output<GetAccountsResult>
Copy
def get_accounts(account_name: Optional[str] = None,
                 instance_id: Optional[str] = None,
                 output_file: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetAccountsResult
def get_accounts_output(account_name: Optional[pulumi.Input[str]] = None,
                 instance_id: Optional[pulumi.Input[str]] = None,
                 output_file: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetAccountsResult]
Copy
func GetAccounts(ctx *Context, args *GetAccountsArgs, opts ...InvokeOption) (*GetAccountsResult, error)
func GetAccountsOutput(ctx *Context, args *GetAccountsOutputArgs, opts ...InvokeOption) GetAccountsResultOutput
Copy

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

public static class GetAccounts 
{
    public static Task<GetAccountsResult> InvokeAsync(GetAccountsArgs args, InvokeOptions? opts = null)
    public static Output<GetAccountsResult> Invoke(GetAccountsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetAccountsResult> getAccounts(GetAccountsArgs args, InvokeOptions options)
public static Output<GetAccountsResult> getAccounts(GetAccountsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: alicloud:mongodb/getAccounts:getAccounts
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

InstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the instance.
AccountName Changes to this property will trigger replacement. string
The name of the account. Valid values: root.
OutputFile string
File name where to save data source results (after running pulumi preview).
InstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the instance.
AccountName Changes to this property will trigger replacement. string
The name of the account. Valid values: root.
OutputFile string
File name where to save data source results (after running pulumi preview).
instanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the instance.
accountName Changes to this property will trigger replacement. String
The name of the account. Valid values: root.
outputFile String
File name where to save data source results (after running pulumi preview).
instanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the instance.
accountName Changes to this property will trigger replacement. string
The name of the account. Valid values: root.
outputFile string
File name where to save data source results (after running pulumi preview).
instance_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the instance.
account_name Changes to this property will trigger replacement. str
The name of the account. Valid values: root.
output_file str
File name where to save data source results (after running pulumi preview).
instanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the instance.
accountName Changes to this property will trigger replacement. String
The name of the account. Valid values: root.
outputFile String
File name where to save data source results (after running pulumi preview).

getAccounts Result

The following output properties are available:

Accounts List<Pulumi.AliCloud.MongoDB.Outputs.GetAccountsAccount>
Id string
The provider-assigned unique ID for this managed resource.
InstanceId string
AccountName string
OutputFile string
Accounts []GetAccountsAccount
Id string
The provider-assigned unique ID for this managed resource.
InstanceId string
AccountName string
OutputFile string
accounts List<GetAccountsAccount>
id String
The provider-assigned unique ID for this managed resource.
instanceId String
accountName String
outputFile String
accounts GetAccountsAccount[]
id string
The provider-assigned unique ID for this managed resource.
instanceId string
accountName string
outputFile string
accounts Sequence[GetAccountsAccount]
id str
The provider-assigned unique ID for this managed resource.
instance_id str
account_name str
output_file str
accounts List<Property Map>
id String
The provider-assigned unique ID for this managed resource.
instanceId String
accountName String
outputFile String

Supporting Types

GetAccountsAccount

AccountDescription This property is required. string
The description of the account.
AccountName This property is required. string
The name of the account.
CharacterType This property is required. string
The role of the account. Valid values: db, cs, mongos, logic, normal.
Id This property is required. string
The ID of the Account. The value formats as <instance_id>:<account_name>.
InstanceId This property is required. string
The id of the instance to which the account belongs.
Status This property is required. string
The status of the account. Valid values: Unavailable, Available.
AccountDescription This property is required. string
The description of the account.
AccountName This property is required. string
The name of the account.
CharacterType This property is required. string
The role of the account. Valid values: db, cs, mongos, logic, normal.
Id This property is required. string
The ID of the Account. The value formats as <instance_id>:<account_name>.
InstanceId This property is required. string
The id of the instance to which the account belongs.
Status This property is required. string
The status of the account. Valid values: Unavailable, Available.
accountDescription This property is required. String
The description of the account.
accountName This property is required. String
The name of the account.
characterType This property is required. String
The role of the account. Valid values: db, cs, mongos, logic, normal.
id This property is required. String
The ID of the Account. The value formats as <instance_id>:<account_name>.
instanceId This property is required. String
The id of the instance to which the account belongs.
status This property is required. String
The status of the account. Valid values: Unavailable, Available.
accountDescription This property is required. string
The description of the account.
accountName This property is required. string
The name of the account.
characterType This property is required. string
The role of the account. Valid values: db, cs, mongos, logic, normal.
id This property is required. string
The ID of the Account. The value formats as <instance_id>:<account_name>.
instanceId This property is required. string
The id of the instance to which the account belongs.
status This property is required. string
The status of the account. Valid values: Unavailable, Available.
account_description This property is required. str
The description of the account.
account_name This property is required. str
The name of the account.
character_type This property is required. str
The role of the account. Valid values: db, cs, mongos, logic, normal.
id This property is required. str
The ID of the Account. The value formats as <instance_id>:<account_name>.
instance_id This property is required. str
The id of the instance to which the account belongs.
status This property is required. str
The status of the account. Valid values: Unavailable, Available.
accountDescription This property is required. String
The description of the account.
accountName This property is required. String
The name of the account.
characterType This property is required. String
The role of the account. Valid values: db, cs, mongos, logic, normal.
id This property is required. String
The ID of the Account. The value formats as <instance_id>:<account_name>.
instanceId This property is required. String
The id of the instance to which the account belongs.
status This property is required. String
The status of the account. Valid values: Unavailable, Available.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi