MongoCollection

Manages a Mongo Collection within a Cosmos DB Account.

Example Usage

using Pulumi;
using Azure = Pulumi.Azure;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleAccount = Output.Create(Azure.CosmosDB.GetAccount.InvokeAsync(new Azure.CosmosDB.GetAccountArgs
        {
            Name = "tfex-cosmosdb-account",
            ResourceGroupName = "tfex-cosmosdb-account-rg",
        }));
        var exampleMongoDatabase = new Azure.CosmosDB.MongoDatabase("exampleMongoDatabase", new Azure.CosmosDB.MongoDatabaseArgs
        {
            ResourceGroupName = exampleAccount.Apply(exampleAccount => exampleAccount.ResourceGroupName),
            AccountName = exampleAccount.Apply(exampleAccount => exampleAccount.Name),
        });
        var exampleMongoCollection = new Azure.CosmosDB.MongoCollection("exampleMongoCollection", new Azure.CosmosDB.MongoCollectionArgs
        {
            ResourceGroupName = exampleAccount.Apply(exampleAccount => exampleAccount.ResourceGroupName),
            AccountName = exampleAccount.Apply(exampleAccount => exampleAccount.Name),
            DatabaseName = exampleMongoDatabase.Name,
            DefaultTtlSeconds = 777,
            ShardKey = "uniqueKey",
            Throughput = 400,
        });
    }

}
package main

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

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        exampleAccount, err := cosmosdb.LookupAccount(ctx, &cosmosdb.LookupAccountArgs{
            Name:              "tfex-cosmosdb-account",
            ResourceGroupName: "tfex-cosmosdb-account-rg",
        }, nil)
        if err != nil {
            return err
        }
        exampleMongoDatabase, err := cosmosdb.NewMongoDatabase(ctx, "exampleMongoDatabase", &cosmosdb.MongoDatabaseArgs{
            ResourceGroupName: pulumi.String(exampleAccount.ResourceGroupName),
            AccountName:       pulumi.String(exampleAccount.Name),
        })
        if err != nil {
            return err
        }
        _, err = cosmosdb.NewMongoCollection(ctx, "exampleMongoCollection", &cosmosdb.MongoCollectionArgs{
            ResourceGroupName: pulumi.String(exampleAccount.ResourceGroupName),
            AccountName:       pulumi.String(exampleAccount.Name),
            DatabaseName:      exampleMongoDatabase.Name,
            DefaultTtlSeconds: pulumi.Int(777),
            ShardKey:          pulumi.String("uniqueKey"),
            Throughput:        pulumi.Int(400),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_azure as azure

example_account = azure.cosmosdb.get_account(name="tfex-cosmosdb-account",
    resource_group_name="tfex-cosmosdb-account-rg")
example_mongo_database = azure.cosmosdb.MongoDatabase("exampleMongoDatabase",
    resource_group_name=example_account.resource_group_name,
    account_name=example_account.name)
example_mongo_collection = azure.cosmosdb.MongoCollection("exampleMongoCollection",
    resource_group_name=example_account.resource_group_name,
    account_name=example_account.name,
    database_name=example_mongo_database.name,
    default_ttl_seconds="777",
    shard_key="uniqueKey",
    throughput=400)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleAccount = azure.cosmosdb.getAccount({
    name: "tfex-cosmosdb-account",
    resourceGroupName: "tfex-cosmosdb-account-rg",
});
const exampleMongoDatabase = new azure.cosmosdb.MongoDatabase("exampleMongoDatabase", {
    resourceGroupName: exampleAccount.then(exampleAccount => exampleAccount.resourceGroupName),
    accountName: exampleAccount.then(exampleAccount => exampleAccount.name),
});
const exampleMongoCollection = new azure.cosmosdb.MongoCollection("exampleMongoCollection", {
    resourceGroupName: exampleAccount.then(exampleAccount => exampleAccount.resourceGroupName),
    accountName: exampleAccount.then(exampleAccount => exampleAccount.name),
    databaseName: exampleMongoDatabase.name,
    defaultTtlSeconds: "777",
    shardKey: "uniqueKey",
    throughput: 400,
});

Create a MongoCollection Resource

def MongoCollection(resource_name, opts=None, account_name=None, database_name=None, default_ttl_seconds=None, indices=None, name=None, resource_group_name=None, shard_key=None, throughput=None, __props__=None);
name string
The unique name of the resource.
args MongoCollectionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args MongoCollectionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args MongoCollectionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

MongoCollection Resource Properties

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

Inputs

The MongoCollection resource accepts the following input properties:

AccountName string
DatabaseName string

The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

DefaultTtlSeconds int

The default Time To Live in seconds. If the value is 0 items are not automatically expired.

Indices List<MongoCollectionIndexArgs>

One or more index blocks as defined below.

Name string

Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.

ShardKey string

The name of the key to partition on for sharding. There must not be any other unique index keys.

Throughput int

The throughput of the MongoDB collection (RU/s). Must be set in increments of 100. The minimum value is 400. This must be set upon database creation otherwise it cannot be updated without a manual resource destroy-apply.

AccountName string
DatabaseName string

The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

DefaultTtlSeconds int

The default Time To Live in seconds. If the value is 0 items are not automatically expired.

Indices []MongoCollectionIndex

One or more index blocks as defined below.

Name string

Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.

ShardKey string

The name of the key to partition on for sharding. There must not be any other unique index keys.

Throughput int

The throughput of the MongoDB collection (RU/s). Must be set in increments of 100. The minimum value is 400. This must be set upon database creation otherwise it cannot be updated without a manual resource destroy-apply.

accountName string
databaseName string

The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

resourceGroupName string

The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

defaultTtlSeconds number

The default Time To Live in seconds. If the value is 0 items are not automatically expired.

indices MongoCollectionIndex[]

One or more index blocks as defined below.

name string

Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.

shardKey string

The name of the key to partition on for sharding. There must not be any other unique index keys.

throughput number

The throughput of the MongoDB collection (RU/s). Must be set in increments of 100. The minimum value is 400. This must be set upon database creation otherwise it cannot be updated without a manual resource destroy-apply.

account_name str
database_name str

The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

resource_group_name str

The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

default_ttl_seconds float

The default Time To Live in seconds. If the value is 0 items are not automatically expired.

indices List[MongoCollectionIndex]

One or more index blocks as defined below.

name str

Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.

shard_key str

The name of the key to partition on for sharding. There must not be any other unique index keys.

throughput float

The throughput of the MongoDB collection (RU/s). Must be set in increments of 100. The minimum value is 400. This must be set upon database creation otherwise it cannot be updated without a manual resource destroy-apply.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
SystemIndexes List<MongoCollectionSystemIndex>

One or more system_indexes blocks as defined below.

Id string
The provider-assigned unique ID for this managed resource.
SystemIndexes []MongoCollectionSystemIndex

One or more system_indexes blocks as defined below.

id string
The provider-assigned unique ID for this managed resource.
systemIndexes MongoCollectionSystemIndex[]

One or more system_indexes blocks as defined below.

id str
The provider-assigned unique ID for this managed resource.
system_indexes List[MongoCollectionSystemIndex]

One or more system_indexes blocks as defined below.

Look up an Existing MongoCollection Resource

Get an existing MongoCollection 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?: MongoCollectionState, opts?: CustomResourceOptions): MongoCollection
static get(resource_name, id, opts=None, account_name=None, database_name=None, default_ttl_seconds=None, indices=None, name=None, resource_group_name=None, shard_key=None, system_indexes=None, throughput=None, __props__=None);
func GetMongoCollection(ctx *Context, name string, id IDInput, state *MongoCollectionState, opts ...ResourceOption) (*MongoCollection, error)
public static MongoCollection Get(string name, Input<string> id, MongoCollectionState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

AccountName string
DatabaseName string

The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

DefaultTtlSeconds int

The default Time To Live in seconds. If the value is 0 items are not automatically expired.

Indices List<MongoCollectionIndexArgs>

One or more index blocks as defined below.

Name string

Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

ShardKey string

The name of the key to partition on for sharding. There must not be any other unique index keys.

SystemIndexes List<MongoCollectionSystemIndexArgs>

One or more system_indexes blocks as defined below.

Throughput int

The throughput of the MongoDB collection (RU/s). Must be set in increments of 100. The minimum value is 400. This must be set upon database creation otherwise it cannot be updated without a manual resource destroy-apply.

AccountName string
DatabaseName string

The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

DefaultTtlSeconds int

The default Time To Live in seconds. If the value is 0 items are not automatically expired.

Indices []MongoCollectionIndex

One or more index blocks as defined below.

Name string

Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.

ResourceGroupName string

The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

ShardKey string

The name of the key to partition on for sharding. There must not be any other unique index keys.

SystemIndexes []MongoCollectionSystemIndex

One or more system_indexes blocks as defined below.

Throughput int

The throughput of the MongoDB collection (RU/s). Must be set in increments of 100. The minimum value is 400. This must be set upon database creation otherwise it cannot be updated without a manual resource destroy-apply.

accountName string
databaseName string

The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

defaultTtlSeconds number

The default Time To Live in seconds. If the value is 0 items are not automatically expired.

indices MongoCollectionIndex[]

One or more index blocks as defined below.

name string

Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.

resourceGroupName string

The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

shardKey string

The name of the key to partition on for sharding. There must not be any other unique index keys.

systemIndexes MongoCollectionSystemIndex[]

One or more system_indexes blocks as defined below.

throughput number

The throughput of the MongoDB collection (RU/s). Must be set in increments of 100. The minimum value is 400. This must be set upon database creation otherwise it cannot be updated without a manual resource destroy-apply.

account_name str
database_name str

The name of the Cosmos DB Mongo Database in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

default_ttl_seconds float

The default Time To Live in seconds. If the value is 0 items are not automatically expired.

indices List[MongoCollectionIndex]

One or more index blocks as defined below.

name str

Specifies the name of the Cosmos DB Mongo Collection. Changing this forces a new resource to be created.

resource_group_name str

The name of the resource group in which the Cosmos DB Mongo Collection is created. Changing this forces a new resource to be created.

shard_key str

The name of the key to partition on for sharding. There must not be any other unique index keys.

system_indexes List[MongoCollectionSystemIndex]

One or more system_indexes blocks as defined below.

throughput float

The throughput of the MongoDB collection (RU/s). Must be set in increments of 100. The minimum value is 400. This must be set upon database creation otherwise it cannot be updated without a manual resource destroy-apply.

Supporting Types

MongoCollectionIndex

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Keys List<string>

Specifies the list of user settable keys for each Cosmos DB Mongo Collection.

Unique bool

Is the index unique or not? Defaults to false.

Keys []string

Specifies the list of user settable keys for each Cosmos DB Mongo Collection.

Unique bool

Is the index unique or not? Defaults to false.

keys string[]

Specifies the list of user settable keys for each Cosmos DB Mongo Collection.

unique boolean

Is the index unique or not? Defaults to false.

keys List[str]

Specifies the list of user settable keys for each Cosmos DB Mongo Collection.

unique bool

Is the index unique or not? Defaults to false.

MongoCollectionSystemIndex

See the output API doc for this type.

See the output API doc for this type.

See the output API doc for this type.

Keys List<string>

Specifies the list of user settable keys for each Cosmos DB Mongo Collection.

Unique bool

Is the index unique or not? Defaults to false.

Keys []string

Specifies the list of user settable keys for each Cosmos DB Mongo Collection.

Unique bool

Is the index unique or not? Defaults to false.

keys string[]

Specifies the list of user settable keys for each Cosmos DB Mongo Collection.

unique boolean

Is the index unique or not? Defaults to false.

keys List[str]

Specifies the list of user settable keys for each Cosmos DB Mongo Collection.

unique bool

Is the index unique or not? Defaults to false.

Package Details

Repository
https://github.com/pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.