The following arguments are supported:
NOTE:
create_mode only works when backup.type is Continuous.
NOTE:
When default_identity_type is a UserAssignedIdentity it must include the User Assigned Identity ID in the following format: UserAssignedIdentity=/subscriptions/{subscriptionId}/resourceGroups/
{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{userAssignedIdentityName}.
NOTE:
To enable the "Allow access from the Azure portal" behavior, you should add the IP addresses provided by the documentation to this list.
NOTE:
To enable the "Accept connections from within public Azure datacenters" behavior, you should add 0.0.0.0 to the list, see the documentation for more details.
NOTE:
When referencing an azurerm_key_vault_key resource, use versionless_id instead of id
NOTE:
In order to use a Custom Key from Key Vault for encryption you must grant Azure Cosmos DB Service access to your key vault. For instructions on how to configure your Key Vault correctly please refer to the product documentation
NOTE:
restore should be set when create_mode is Restore.
The consistency_policy block Configures the database consistency and supports the following:
Note:
max_interval_in_seconds and max_staleness_prefix can only be set to custom values when consistency_level is set to BoundedStaleness - otherwise they will return the default values shown above.
The geo_location block Configures the geographic locations the data is replicated to and supports the following:
A capabilities block Configures the capabilities to be enabled for this Cosmos DB account:
NOTE:
Setting MongoDBv3.4 also requires setting EnableMongo.
NOTE:
Only AllowSelfServeUpgradeToMongo36, DisableRateLimitingResponses, EnableAggregationPipeline, MongoDBv3.4, EnableMongoRetryableWrites, EnableMongoRoleBasedAccessControl, EnableUniqueCompoundNestedDocs, EnableMongo16MBDocumentSupport and mongoEnableDocLevelTTL can be added to an existing Cosmos DB account.
NOTE:
Only DisableRateLimitingResponses and EnableMongoRetryableWrites can be removed from an existing Cosmos DB account.
The virtual_network_rule block Configures the virtual network subnets allowed to access this Cosmos DB account and supports the following:
An analytical_storage block supports the following:
A capacity block supports the following:
A backup block supports the following:
A cors_rule block supports the following:
An identity block supports the following:
A restore block supports the following:
NOTE:
Any database account with Continuous type (live account or accounts deleted in last 30 days) is a restorable database account and there cannot be Create/Update/Delete operations on the restorable database accounts. They can only be read and retrieved by azurerm_cosmosdb_restorable_database_accounts.
A database block supports the following:
resource "azurerm_resource_group" "example" {
name = "example-resource-group"
location = "West Europe"
}
resource "random_integer" "ri" {
min = 10000
max = 99999
}
resource "azurerm_cosmosdb_account" "db" {
name = "tfex-cosmos-db-${random_integer.ri.result}"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
offer_type = "Standard"
kind = "MongoDB"
enable_automatic_failover = true
capabilities {
name = "EnableAggregationPipeline"
}
capabilities {
name = "mongoEnableDocLevelTTL"
}
capabilities {
name = "MongoDBv3.4"
}
capabilities {
name = "EnableMongo"
}
consistency_policy {
consistency_level = "BoundedStaleness"
max_interval_in_seconds = 300
max_staleness_prefix = 100000
}
geo_location {
location = "eastus"
failover_priority = 1
}
geo_location {
location = "westus"
failover_priority = 0
}
}
az cosmosdb create --name
--resource-group
[--analytical-storage-schema-type {FullFidelity, WellDefined}]
[--assign-identity]
[--backup-interval]
[--backup-policy-type {Continuous, Periodic}]
[--backup-redundancy {Geo, Local, Zone}]
[--backup-retention]
[--capabilities]
[--databases-to-restore]
[--default-consistency-level {BoundedStaleness, ConsistentPrefix, Eventual, Session, Strong}]
[--default-identity]
[--disable-key-based-metadata-write-access {false, true}]
[--enable-analytical-storage {false, true}]
[--enable-automatic-failover {false, true}]
[--enable-free-tier {false, true}]
[--enable-multiple-write-locations {false, true}]
[--enable-public-network {false, true}]
[--enable-virtual-network {false, true}]
[--gremlin-databases-to-restore]
[--ip-range-filter]
[--is-restore-request {false, true}]
[--key-uri]
[--kind {GlobalDocumentDB, MongoDB, Parse}]
[--locations]
[--max-interval]
[--max-staleness-prefix]
[--network-acl-bypass {AzureServices, None}]
[--network-acl-bypass-resource-ids]
[--restore-source]
[--restore-timestamp]
[--server-version {3.2, 3.6, 4.0, 4.2}]
[--tables-to-restore]
[--tags]
[--virtual-network-rules]
az cosmosdb create --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --subscription MySubscription
Categorized by Availability, Security & Compliance and Cost