1. Packages
  2. Azure Native
  3. API Docs
  4. cosmosdb
  5. MongoDBResourceMongoUserDefinition
This is the latest version of Azure Native. Use the Azure Native v2 docs if using the v2 version of this package.
Azure Native v3.1.0 published on Tuesday, Apr 8, 2025 by Pulumi

azure-native.cosmosdb.MongoDBResourceMongoUserDefinition

Explore with Pulumi AI

An Azure Cosmos DB User Definition

Uses Azure REST API version 2024-11-15.

Other available API versions: 2021-10-15-preview, 2021-11-15-preview, 2022-02-15-preview, 2022-05-15-preview, 2022-08-15, 2022-08-15-preview, 2022-11-15, 2022-11-15-preview, 2023-03-01-preview, 2023-03-15, 2023-03-15-preview, 2023-04-15, 2023-09-15, 2023-09-15-preview, 2023-11-15, 2023-11-15-preview, 2024-02-15-preview, 2024-05-15, 2024-05-15-preview, 2024-08-15, 2024-09-01-preview, 2024-12-01-preview. These can be accessed by generating a local SDK package using the CLI command pulumi package add azure-native cosmosdb [ApiVersion]. See the version guide for details.

Example Usage

CosmosDBMongoDBUserDefinitionCreateUpdate

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var mongoDBResourceMongoUserDefinition = new AzureNative.CosmosDB.MongoDBResourceMongoUserDefinition("mongoDBResourceMongoUserDefinition", new()
    {
        AccountName = "myAccountName",
        CustomData = "My custom data",
        DatabaseName = "sales",
        Mechanisms = "SCRAM-SHA-256",
        MongoUserDefinitionId = "myMongoUserDefinitionId",
        Password = "myPassword",
        ResourceGroupName = "myResourceGroupName",
        Roles = new[]
        {
            new AzureNative.CosmosDB.Inputs.RoleArgs
            {
                Db = "sales",
                Role = "myReadRole",
            },
        },
        UserName = "myUserName",
    });

});
Copy
package main

import (
	cosmosdb "github.com/pulumi/pulumi-azure-native-sdk/cosmosdb/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cosmosdb.NewMongoDBResourceMongoUserDefinition(ctx, "mongoDBResourceMongoUserDefinition", &cosmosdb.MongoDBResourceMongoUserDefinitionArgs{
			AccountName:           pulumi.String("myAccountName"),
			CustomData:            pulumi.String("My custom data"),
			DatabaseName:          pulumi.String("sales"),
			Mechanisms:            pulumi.String("SCRAM-SHA-256"),
			MongoUserDefinitionId: pulumi.String("myMongoUserDefinitionId"),
			Password:              pulumi.String("myPassword"),
			ResourceGroupName:     pulumi.String("myResourceGroupName"),
			Roles: cosmosdb.RoleArray{
				&cosmosdb.RoleArgs{
					Db:   pulumi.String("sales"),
					Role: pulumi.String("myReadRole"),
				},
			},
			UserName: pulumi.String("myUserName"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.cosmosdb.MongoDBResourceMongoUserDefinition;
import com.pulumi.azurenative.cosmosdb.MongoDBResourceMongoUserDefinitionArgs;
import com.pulumi.azurenative.cosmosdb.inputs.RoleArgs;
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 mongoDBResourceMongoUserDefinition = new MongoDBResourceMongoUserDefinition("mongoDBResourceMongoUserDefinition", MongoDBResourceMongoUserDefinitionArgs.builder()
            .accountName("myAccountName")
            .customData("My custom data")
            .databaseName("sales")
            .mechanisms("SCRAM-SHA-256")
            .mongoUserDefinitionId("myMongoUserDefinitionId")
            .password("myPassword")
            .resourceGroupName("myResourceGroupName")
            .roles(RoleArgs.builder()
                .db("sales")
                .role("myReadRole")
                .build())
            .userName("myUserName")
            .build());

    }
}
Copy
import * as pulumi from "@pulumi/pulumi";
import * as azure_native from "@pulumi/azure-native";

const mongoDBResourceMongoUserDefinition = new azure_native.cosmosdb.MongoDBResourceMongoUserDefinition("mongoDBResourceMongoUserDefinition", {
    accountName: "myAccountName",
    customData: "My custom data",
    databaseName: "sales",
    mechanisms: "SCRAM-SHA-256",
    mongoUserDefinitionId: "myMongoUserDefinitionId",
    password: "myPassword",
    resourceGroupName: "myResourceGroupName",
    roles: [{
        db: "sales",
        role: "myReadRole",
    }],
    userName: "myUserName",
});
Copy
import pulumi
import pulumi_azure_native as azure_native

mongo_db_resource_mongo_user_definition = azure_native.cosmosdb.MongoDBResourceMongoUserDefinition("mongoDBResourceMongoUserDefinition",
    account_name="myAccountName",
    custom_data="My custom data",
    database_name="sales",
    mechanisms="SCRAM-SHA-256",
    mongo_user_definition_id="myMongoUserDefinitionId",
    password="myPassword",
    resource_group_name="myResourceGroupName",
    roles=[{
        "db": "sales",
        "role": "myReadRole",
    }],
    user_name="myUserName")
Copy
resources:
  mongoDBResourceMongoUserDefinition:
    type: azure-native:cosmosdb:MongoDBResourceMongoUserDefinition
    properties:
      accountName: myAccountName
      customData: My custom data
      databaseName: sales
      mechanisms: SCRAM-SHA-256
      mongoUserDefinitionId: myMongoUserDefinitionId
      password: myPassword
      resourceGroupName: myResourceGroupName
      roles:
        - db: sales
          role: myReadRole
      userName: myUserName
Copy

Create MongoDBResourceMongoUserDefinition Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new MongoDBResourceMongoUserDefinition(name: string, args: MongoDBResourceMongoUserDefinitionArgs, opts?: CustomResourceOptions);
@overload
def MongoDBResourceMongoUserDefinition(resource_name: str,
                                       args: MongoDBResourceMongoUserDefinitionArgs,
                                       opts: Optional[ResourceOptions] = None)

@overload
def MongoDBResourceMongoUserDefinition(resource_name: str,
                                       opts: Optional[ResourceOptions] = None,
                                       account_name: Optional[str] = None,
                                       resource_group_name: Optional[str] = None,
                                       custom_data: Optional[str] = None,
                                       database_name: Optional[str] = None,
                                       mechanisms: Optional[str] = None,
                                       mongo_user_definition_id: Optional[str] = None,
                                       password: Optional[str] = None,
                                       roles: Optional[Sequence[RoleArgs]] = None,
                                       user_name: Optional[str] = None)
func NewMongoDBResourceMongoUserDefinition(ctx *Context, name string, args MongoDBResourceMongoUserDefinitionArgs, opts ...ResourceOption) (*MongoDBResourceMongoUserDefinition, error)
public MongoDBResourceMongoUserDefinition(string name, MongoDBResourceMongoUserDefinitionArgs args, CustomResourceOptions? opts = null)
public MongoDBResourceMongoUserDefinition(String name, MongoDBResourceMongoUserDefinitionArgs args)
public MongoDBResourceMongoUserDefinition(String name, MongoDBResourceMongoUserDefinitionArgs args, CustomResourceOptions options)
type: azure-native:cosmosdb:MongoDBResourceMongoUserDefinition
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. MongoDBResourceMongoUserDefinitionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. MongoDBResourceMongoUserDefinitionArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. MongoDBResourceMongoUserDefinitionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. MongoDBResourceMongoUserDefinitionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. MongoDBResourceMongoUserDefinitionArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var mongoDBResourceMongoUserDefinitionResource = new AzureNative.CosmosDB.MongoDBResourceMongoUserDefinition("mongoDBResourceMongoUserDefinitionResource", new()
{
    AccountName = "string",
    ResourceGroupName = "string",
    CustomData = "string",
    DatabaseName = "string",
    Mechanisms = "string",
    MongoUserDefinitionId = "string",
    Password = "string",
    Roles = new[]
    {
        new AzureNative.CosmosDB.Inputs.RoleArgs
        {
            Db = "string",
            Role = "string",
        },
    },
    UserName = "string",
});
Copy
example, err := cosmosdb.NewMongoDBResourceMongoUserDefinition(ctx, "mongoDBResourceMongoUserDefinitionResource", &cosmosdb.MongoDBResourceMongoUserDefinitionArgs{
	AccountName:           pulumi.String("string"),
	ResourceGroupName:     pulumi.String("string"),
	CustomData:            pulumi.String("string"),
	DatabaseName:          pulumi.String("string"),
	Mechanisms:            pulumi.String("string"),
	MongoUserDefinitionId: pulumi.String("string"),
	Password:              pulumi.String("string"),
	Roles: cosmosdb.RoleArray{
		&cosmosdb.RoleArgs{
			Db:   pulumi.String("string"),
			Role: pulumi.String("string"),
		},
	},
	UserName: pulumi.String("string"),
})
Copy
var mongoDBResourceMongoUserDefinitionResource = new MongoDBResourceMongoUserDefinition("mongoDBResourceMongoUserDefinitionResource", MongoDBResourceMongoUserDefinitionArgs.builder()
    .accountName("string")
    .resourceGroupName("string")
    .customData("string")
    .databaseName("string")
    .mechanisms("string")
    .mongoUserDefinitionId("string")
    .password("string")
    .roles(RoleArgs.builder()
        .db("string")
        .role("string")
        .build())
    .userName("string")
    .build());
Copy
mongo_db_resource_mongo_user_definition_resource = azure_native.cosmosdb.MongoDBResourceMongoUserDefinition("mongoDBResourceMongoUserDefinitionResource",
    account_name="string",
    resource_group_name="string",
    custom_data="string",
    database_name="string",
    mechanisms="string",
    mongo_user_definition_id="string",
    password="string",
    roles=[{
        "db": "string",
        "role": "string",
    }],
    user_name="string")
Copy
const mongoDBResourceMongoUserDefinitionResource = new azure_native.cosmosdb.MongoDBResourceMongoUserDefinition("mongoDBResourceMongoUserDefinitionResource", {
    accountName: "string",
    resourceGroupName: "string",
    customData: "string",
    databaseName: "string",
    mechanisms: "string",
    mongoUserDefinitionId: "string",
    password: "string",
    roles: [{
        db: "string",
        role: "string",
    }],
    userName: "string",
});
Copy
type: azure-native:cosmosdb:MongoDBResourceMongoUserDefinition
properties:
    accountName: string
    customData: string
    databaseName: string
    mechanisms: string
    mongoUserDefinitionId: string
    password: string
    resourceGroupName: string
    roles:
        - db: string
          role: string
    userName: string
Copy

MongoDBResourceMongoUserDefinition Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The MongoDBResourceMongoUserDefinition resource accepts the following input properties:

AccountName
This property is required.
Changes to this property will trigger replacement.
string
Cosmos DB database account name.
ResourceGroupName
This property is required.
Changes to this property will trigger replacement.
string
The name of the resource group. The name is case insensitive.
CustomData string
A custom definition for the USer Definition.
DatabaseName string
The database name for which access is being granted for this User Definition.
Mechanisms string
The Mongo Auth mechanism. For now, we only support auth mechanism SCRAM-SHA-256.
MongoUserDefinitionId Changes to this property will trigger replacement. string
The ID for the User Definition {dbName.userName}.
Password string
The password for User Definition. Response does not contain user password.
Roles List<Pulumi.AzureNative.CosmosDB.Inputs.Role>
The set of roles inherited by the User Definition.
UserName string
The user name for User Definition.
AccountName
This property is required.
Changes to this property will trigger replacement.
string
Cosmos DB database account name.
ResourceGroupName
This property is required.
Changes to this property will trigger replacement.
string
The name of the resource group. The name is case insensitive.
CustomData string
A custom definition for the USer Definition.
DatabaseName string
The database name for which access is being granted for this User Definition.
Mechanisms string
The Mongo Auth mechanism. For now, we only support auth mechanism SCRAM-SHA-256.
MongoUserDefinitionId Changes to this property will trigger replacement. string
The ID for the User Definition {dbName.userName}.
Password string
The password for User Definition. Response does not contain user password.
Roles []RoleArgs
The set of roles inherited by the User Definition.
UserName string
The user name for User Definition.
accountName
This property is required.
Changes to this property will trigger replacement.
String
Cosmos DB database account name.
resourceGroupName
This property is required.
Changes to this property will trigger replacement.
String
The name of the resource group. The name is case insensitive.
customData String
A custom definition for the USer Definition.
databaseName String
The database name for which access is being granted for this User Definition.
mechanisms String
The Mongo Auth mechanism. For now, we only support auth mechanism SCRAM-SHA-256.
mongoUserDefinitionId Changes to this property will trigger replacement. String
The ID for the User Definition {dbName.userName}.
password String
The password for User Definition. Response does not contain user password.
roles List<Role>
The set of roles inherited by the User Definition.
userName String
The user name for User Definition.
accountName
This property is required.
Changes to this property will trigger replacement.
string
Cosmos DB database account name.
resourceGroupName
This property is required.
Changes to this property will trigger replacement.
string
The name of the resource group. The name is case insensitive.
customData string
A custom definition for the USer Definition.
databaseName string
The database name for which access is being granted for this User Definition.
mechanisms string
The Mongo Auth mechanism. For now, we only support auth mechanism SCRAM-SHA-256.
mongoUserDefinitionId Changes to this property will trigger replacement. string
The ID for the User Definition {dbName.userName}.
password string
The password for User Definition. Response does not contain user password.
roles Role[]
The set of roles inherited by the User Definition.
userName string
The user name for User Definition.
account_name
This property is required.
Changes to this property will trigger replacement.
str
Cosmos DB database account name.
resource_group_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the resource group. The name is case insensitive.
custom_data str
A custom definition for the USer Definition.
database_name str
The database name for which access is being granted for this User Definition.
mechanisms str
The Mongo Auth mechanism. For now, we only support auth mechanism SCRAM-SHA-256.
mongo_user_definition_id Changes to this property will trigger replacement. str
The ID for the User Definition {dbName.userName}.
password str
The password for User Definition. Response does not contain user password.
roles Sequence[RoleArgs]
The set of roles inherited by the User Definition.
user_name str
The user name for User Definition.
accountName
This property is required.
Changes to this property will trigger replacement.
String
Cosmos DB database account name.
resourceGroupName
This property is required.
Changes to this property will trigger replacement.
String
The name of the resource group. The name is case insensitive.
customData String
A custom definition for the USer Definition.
databaseName String
The database name for which access is being granted for this User Definition.
mechanisms String
The Mongo Auth mechanism. For now, we only support auth mechanism SCRAM-SHA-256.
mongoUserDefinitionId Changes to this property will trigger replacement. String
The ID for the User Definition {dbName.userName}.
password String
The password for User Definition. Response does not contain user password.
roles List<Property Map>
The set of roles inherited by the User Definition.
userName String
The user name for User Definition.

Outputs

All input properties are implicitly available as output properties. Additionally, the MongoDBResourceMongoUserDefinition resource produces the following output properties:

AzureApiVersion string
The Azure API version of the resource.
Id string
The provider-assigned unique ID for this managed resource.
Name string
The name of the database account.
Type string
The type of Azure resource.
AzureApiVersion string
The Azure API version of the resource.
Id string
The provider-assigned unique ID for this managed resource.
Name string
The name of the database account.
Type string
The type of Azure resource.
azureApiVersion String
The Azure API version of the resource.
id String
The provider-assigned unique ID for this managed resource.
name String
The name of the database account.
type String
The type of Azure resource.
azureApiVersion string
The Azure API version of the resource.
id string
The provider-assigned unique ID for this managed resource.
name string
The name of the database account.
type string
The type of Azure resource.
azure_api_version str
The Azure API version of the resource.
id str
The provider-assigned unique ID for this managed resource.
name str
The name of the database account.
type str
The type of Azure resource.
azureApiVersion String
The Azure API version of the resource.
id String
The provider-assigned unique ID for this managed resource.
name String
The name of the database account.
type String
The type of Azure resource.

Supporting Types

Role
, RoleArgs

Db string
The database name the role is applied.
Role string
The role name.
Db string
The database name the role is applied.
Role string
The role name.
db String
The database name the role is applied.
role String
The role name.
db string
The database name the role is applied.
role string
The role name.
db str
The database name the role is applied.
role str
The role name.
db String
The database name the role is applied.
role String
The role name.

RoleResponse
, RoleResponseArgs

Db string
The database name the role is applied.
Role string
The role name.
Db string
The database name the role is applied.
Role string
The role name.
db String
The database name the role is applied.
role String
The role name.
db string
The database name the role is applied.
role string
The role name.
db str
The database name the role is applied.
role str
The role name.
db String
The database name the role is applied.
role String
The role name.

Import

An existing resource can be imported using its type token, name, and identifier, e.g.

$ pulumi import azure-native:cosmosdb:MongoDBResourceMongoUserDefinition myUserName /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId} 
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Azure Native pulumi/pulumi-azure-native
License
Apache-2.0