We recommend using Azure Native.
azure.cosmosdb.MongoUserDefinition
Explore with Pulumi AI
Manages a Cosmos DB Mongo User Definition.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleAccount = new azure.cosmosdb.Account("example", {
name: "example-ca",
location: example.location,
resourceGroupName: example.name,
offerType: "Standard",
kind: "MongoDB",
capabilities: [
{
name: "EnableMongo",
},
{
name: "EnableMongoRoleBasedAccessControl",
},
],
consistencyPolicy: {
consistencyLevel: "Strong",
},
geoLocations: [{
location: example.location,
failoverPriority: 0,
}],
});
const exampleMongoDatabase = new azure.cosmosdb.MongoDatabase("example", {
name: "example-mongodb",
resourceGroupName: exampleAccount.resourceGroupName,
accountName: exampleAccount.name,
});
const exampleMongoUserDefinition = new azure.cosmosdb.MongoUserDefinition("example", {
cosmosMongoDatabaseId: exampleMongoDatabase.id,
username: "myUserName",
password: "myPassword",
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_account = azure.cosmosdb.Account("example",
name="example-ca",
location=example.location,
resource_group_name=example.name,
offer_type="Standard",
kind="MongoDB",
capabilities=[
{
"name": "EnableMongo",
},
{
"name": "EnableMongoRoleBasedAccessControl",
},
],
consistency_policy={
"consistency_level": "Strong",
},
geo_locations=[{
"location": example.location,
"failover_priority": 0,
}])
example_mongo_database = azure.cosmosdb.MongoDatabase("example",
name="example-mongodb",
resource_group_name=example_account.resource_group_name,
account_name=example_account.name)
example_mongo_user_definition = azure.cosmosdb.MongoUserDefinition("example",
cosmos_mongo_database_id=example_mongo_database.id,
username="myUserName",
password="myPassword")
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/cosmosdb"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleAccount, err := cosmosdb.NewAccount(ctx, "example", &cosmosdb.AccountArgs{
Name: pulumi.String("example-ca"),
Location: example.Location,
ResourceGroupName: example.Name,
OfferType: pulumi.String("Standard"),
Kind: pulumi.String("MongoDB"),
Capabilities: cosmosdb.AccountCapabilityArray{
&cosmosdb.AccountCapabilityArgs{
Name: pulumi.String("EnableMongo"),
},
&cosmosdb.AccountCapabilityArgs{
Name: pulumi.String("EnableMongoRoleBasedAccessControl"),
},
},
ConsistencyPolicy: &cosmosdb.AccountConsistencyPolicyArgs{
ConsistencyLevel: pulumi.String("Strong"),
},
GeoLocations: cosmosdb.AccountGeoLocationArray{
&cosmosdb.AccountGeoLocationArgs{
Location: example.Location,
FailoverPriority: pulumi.Int(0),
},
},
})
if err != nil {
return err
}
exampleMongoDatabase, err := cosmosdb.NewMongoDatabase(ctx, "example", &cosmosdb.MongoDatabaseArgs{
Name: pulumi.String("example-mongodb"),
ResourceGroupName: exampleAccount.ResourceGroupName,
AccountName: exampleAccount.Name,
})
if err != nil {
return err
}
_, err = cosmosdb.NewMongoUserDefinition(ctx, "example", &cosmosdb.MongoUserDefinitionArgs{
CosmosMongoDatabaseId: exampleMongoDatabase.ID(),
Username: pulumi.String("myUserName"),
Password: pulumi.String("myPassword"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleAccount = new Azure.CosmosDB.Account("example", new()
{
Name = "example-ca",
Location = example.Location,
ResourceGroupName = example.Name,
OfferType = "Standard",
Kind = "MongoDB",
Capabilities = new[]
{
new Azure.CosmosDB.Inputs.AccountCapabilityArgs
{
Name = "EnableMongo",
},
new Azure.CosmosDB.Inputs.AccountCapabilityArgs
{
Name = "EnableMongoRoleBasedAccessControl",
},
},
ConsistencyPolicy = new Azure.CosmosDB.Inputs.AccountConsistencyPolicyArgs
{
ConsistencyLevel = "Strong",
},
GeoLocations = new[]
{
new Azure.CosmosDB.Inputs.AccountGeoLocationArgs
{
Location = example.Location,
FailoverPriority = 0,
},
},
});
var exampleMongoDatabase = new Azure.CosmosDB.MongoDatabase("example", new()
{
Name = "example-mongodb",
ResourceGroupName = exampleAccount.ResourceGroupName,
AccountName = exampleAccount.Name,
});
var exampleMongoUserDefinition = new Azure.CosmosDB.MongoUserDefinition("example", new()
{
CosmosMongoDatabaseId = exampleMongoDatabase.Id,
Username = "myUserName",
Password = "myPassword",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.cosmosdb.Account;
import com.pulumi.azure.cosmosdb.AccountArgs;
import com.pulumi.azure.cosmosdb.inputs.AccountCapabilityArgs;
import com.pulumi.azure.cosmosdb.inputs.AccountConsistencyPolicyArgs;
import com.pulumi.azure.cosmosdb.inputs.AccountGeoLocationArgs;
import com.pulumi.azure.cosmosdb.MongoDatabase;
import com.pulumi.azure.cosmosdb.MongoDatabaseArgs;
import com.pulumi.azure.cosmosdb.MongoUserDefinition;
import com.pulumi.azure.cosmosdb.MongoUserDefinitionArgs;
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 ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
.name("example-ca")
.location(example.location())
.resourceGroupName(example.name())
.offerType("Standard")
.kind("MongoDB")
.capabilities(
AccountCapabilityArgs.builder()
.name("EnableMongo")
.build(),
AccountCapabilityArgs.builder()
.name("EnableMongoRoleBasedAccessControl")
.build())
.consistencyPolicy(AccountConsistencyPolicyArgs.builder()
.consistencyLevel("Strong")
.build())
.geoLocations(AccountGeoLocationArgs.builder()
.location(example.location())
.failoverPriority(0)
.build())
.build());
var exampleMongoDatabase = new MongoDatabase("exampleMongoDatabase", MongoDatabaseArgs.builder()
.name("example-mongodb")
.resourceGroupName(exampleAccount.resourceGroupName())
.accountName(exampleAccount.name())
.build());
var exampleMongoUserDefinition = new MongoUserDefinition("exampleMongoUserDefinition", MongoUserDefinitionArgs.builder()
.cosmosMongoDatabaseId(exampleMongoDatabase.id())
.username("myUserName")
.password("myPassword")
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
location: West Europe
exampleAccount:
type: azure:cosmosdb:Account
name: example
properties:
name: example-ca
location: ${example.location}
resourceGroupName: ${example.name}
offerType: Standard
kind: MongoDB
capabilities:
- name: EnableMongo
- name: EnableMongoRoleBasedAccessControl
consistencyPolicy:
consistencyLevel: Strong
geoLocations:
- location: ${example.location}
failoverPriority: 0
exampleMongoDatabase:
type: azure:cosmosdb:MongoDatabase
name: example
properties:
name: example-mongodb
resourceGroupName: ${exampleAccount.resourceGroupName}
accountName: ${exampleAccount.name}
exampleMongoUserDefinition:
type: azure:cosmosdb:MongoUserDefinition
name: example
properties:
cosmosMongoDatabaseId: ${exampleMongoDatabase.id}
username: myUserName
password: myPassword
Create MongoUserDefinition Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new MongoUserDefinition(name: string, args: MongoUserDefinitionArgs, opts?: CustomResourceOptions);
@overload
def MongoUserDefinition(resource_name: str,
args: MongoUserDefinitionArgs,
opts: Optional[ResourceOptions] = None)
@overload
def MongoUserDefinition(resource_name: str,
opts: Optional[ResourceOptions] = None,
cosmos_mongo_database_id: Optional[str] = None,
password: Optional[str] = None,
username: Optional[str] = None,
inherited_role_names: Optional[Sequence[str]] = None)
func NewMongoUserDefinition(ctx *Context, name string, args MongoUserDefinitionArgs, opts ...ResourceOption) (*MongoUserDefinition, error)
public MongoUserDefinition(string name, MongoUserDefinitionArgs args, CustomResourceOptions? opts = null)
public MongoUserDefinition(String name, MongoUserDefinitionArgs args)
public MongoUserDefinition(String name, MongoUserDefinitionArgs args, CustomResourceOptions options)
type: azure:cosmosdb:MongoUserDefinition
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args MongoUserDefinitionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args MongoUserDefinitionArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args MongoUserDefinitionArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args MongoUserDefinitionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args MongoUserDefinitionArgs
- 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 mongoUserDefinitionResource = new Azure.CosmosDB.MongoUserDefinition("mongoUserDefinitionResource", new()
{
CosmosMongoDatabaseId = "string",
Password = "string",
Username = "string",
InheritedRoleNames = new[]
{
"string",
},
});
example, err := cosmosdb.NewMongoUserDefinition(ctx, "mongoUserDefinitionResource", &cosmosdb.MongoUserDefinitionArgs{
CosmosMongoDatabaseId: pulumi.String("string"),
Password: pulumi.String("string"),
Username: pulumi.String("string"),
InheritedRoleNames: pulumi.StringArray{
pulumi.String("string"),
},
})
var mongoUserDefinitionResource = new MongoUserDefinition("mongoUserDefinitionResource", MongoUserDefinitionArgs.builder()
.cosmosMongoDatabaseId("string")
.password("string")
.username("string")
.inheritedRoleNames("string")
.build());
mongo_user_definition_resource = azure.cosmosdb.MongoUserDefinition("mongoUserDefinitionResource",
cosmos_mongo_database_id="string",
password="string",
username="string",
inherited_role_names=["string"])
const mongoUserDefinitionResource = new azure.cosmosdb.MongoUserDefinition("mongoUserDefinitionResource", {
cosmosMongoDatabaseId: "string",
password: "string",
username: "string",
inheritedRoleNames: ["string"],
});
type: azure:cosmosdb:MongoUserDefinition
properties:
cosmosMongoDatabaseId: string
inheritedRoleNames:
- string
password: string
username: string
MongoUserDefinition Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The MongoUserDefinition resource accepts the following input properties:
- Cosmos
Mongo stringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- Password string
- The password for the Mongo User Definition.
- Username string
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- Inherited
Role List<string>Names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.
- Cosmos
Mongo stringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- Password string
- The password for the Mongo User Definition.
- Username string
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- Inherited
Role []stringNames A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.
- cosmos
Mongo StringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- password String
- The password for the Mongo User Definition.
- username String
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- inherited
Role List<String>Names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.
- cosmos
Mongo stringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- password string
- The password for the Mongo User Definition.
- username string
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- inherited
Role string[]Names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.
- cosmos_
mongo_ strdatabase_ id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- password str
- The password for the Mongo User Definition.
- username str
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- inherited_
role_ Sequence[str]names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.
- cosmos
Mongo StringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- password String
- The password for the Mongo User Definition.
- username String
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- inherited
Role List<String>Names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.
Outputs
All input properties are implicitly available as output properties. Additionally, the MongoUserDefinition resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing MongoUserDefinition Resource
Get an existing MongoUserDefinition resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: MongoUserDefinitionState, opts?: CustomResourceOptions): MongoUserDefinition
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
cosmos_mongo_database_id: Optional[str] = None,
inherited_role_names: Optional[Sequence[str]] = None,
password: Optional[str] = None,
username: Optional[str] = None) -> MongoUserDefinition
func GetMongoUserDefinition(ctx *Context, name string, id IDInput, state *MongoUserDefinitionState, opts ...ResourceOption) (*MongoUserDefinition, error)
public static MongoUserDefinition Get(string name, Input<string> id, MongoUserDefinitionState? state, CustomResourceOptions? opts = null)
public static MongoUserDefinition get(String name, Output<String> id, MongoUserDefinitionState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Cosmos
Mongo stringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- Inherited
Role List<string>Names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.- Password string
- The password for the Mongo User Definition.
- Username string
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- Cosmos
Mongo stringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- Inherited
Role []stringNames A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.- Password string
- The password for the Mongo User Definition.
- Username string
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- cosmos
Mongo StringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- inherited
Role List<String>Names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.- password String
- The password for the Mongo User Definition.
- username String
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- cosmos
Mongo stringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- inherited
Role string[]Names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.- password string
- The password for the Mongo User Definition.
- username string
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- cosmos_
mongo_ strdatabase_ id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- inherited_
role_ Sequence[str]names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.- password str
- The password for the Mongo User Definition.
- username str
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
- cosmos
Mongo StringDatabase Id - The resource ID of the Mongo DB. Changing this forces a new resource to be created.
- inherited
Role List<String>Names A list of Mongo Roles that are inherited to the Mongo User Definition.
Note: The role that needs to be inherited should exist in the Mongo DB of
cosmos_mongo_database_id
.- password String
- The password for the Mongo User Definition.
- username String
- The username for the Mongo User Definition. Changing this forces a new resource to be created.
Import
Cosmos DB Mongo User Definitions can be imported using the resource id
, e.g.
$ pulumi import azure:cosmosdb/mongoUserDefinition:MongoUserDefinition example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/mongodbUserDefinitions/dbname1.username1
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurerm
Terraform Provider.