yandex_mdb_mongodb_cluster (Resource)
Written by
Updated at August 7, 2025
- Example usage
- Schema
- Required
- Optional
- Read-Only
- Nested Schema for cluster_config
- Nested Schema for cluster_config.access
- Nested Schema for cluster_config.backup_window_start
- Nested Schema for cluster_config.mongocfg
- Nested Schema for cluster_config.mongocfg.net
- Nested Schema for cluster_config.mongocfg.operation_profiling
- Nested Schema for cluster_config.mongocfg.storage
- Nested Schema for cluster_config.mongocfg.storage.wired_tiger
- Nested Schema for cluster_config.mongod
- Nested Schema for cluster_config.mongod.audit_log
- Nested Schema for cluster_config.mongod.net
- Nested Schema for cluster_config.mongod.operation_profiling
- Nested Schema for cluster_config.mongod.security
- Nested Schema for cluster_config.mongod.security.kmip
- Nested Schema for cluster_config.mongod.set_parameter
- Nested Schema for cluster_config.mongod.storage
- Nested Schema for cluster_config.mongod.storage.journal
- Nested Schema for cluster_config.mongod.storage.wired_tiger
- Nested Schema for cluster_config.mongos
- Nested Schema for cluster_config.mongos.net
- Nested Schema for cluster_config.performance_diagnostics
- Nested Schema for host
- Nested Schema for host.host_parameters
- Nested Schema for database
- Nested Schema for disk_size_autoscaling_mongocfg
- Nested Schema for disk_size_autoscaling_mongod
- Nested Schema for disk_size_autoscaling_mongoinfra
- Nested Schema for disk_size_autoscaling_mongos
- Nested Schema for maintenance_window
- Nested Schema for resources
- Nested Schema for resources_mongocfg
- Nested Schema for resources_mongod
- Nested Schema for resources_mongoinfra
- Nested Schema for resources_mongos
- Nested Schema for restore
- Nested Schema for timeouts
- Nested Schema for user
- Nested Schema for user.permission
- Import
Manages a MongoDB cluster within the Yandex Cloud. For more information, see the official documentation.
Example usage
//
// Create a new MDB MongoDB Cluster.
//
resource "yandex_mdb_mongodb_cluster" "my_cluster" {
name = "test"
environment = "PRESTABLE"
network_id = yandex_vpc_network.foo.id
cluster_config {
version = "4.2"
}
labels = {
test_key = "test_value"
}
database {
name = "testdb"
}
user {
name = "john"
password = "password"
permission {
database_name = "testdb"
}
}
resources_mongod {
resource_preset_id = "s2.small"
disk_size = 16
disk_type_id = "network-hdd"
}
resources_mongos {
resource_preset_id = "s2.small"
disk_size = 14
disk_type_id = "network-hdd"
}
resources_mongocfg {
resource_preset_id = "s2.small"
disk_size = 14
disk_type_id = "network-hdd"
}
host {
zone_id = "ru-central1-d"
subnet_id = yandex_vpc_subnet.foo.id
}
maintenance_window {
type = "ANYTIME"
}
}
// Auxiliary resources
resource "yandex_vpc_network" "foo" {}
resource "yandex_vpc_subnet" "foo" {
zone = "ru-central1-d"
network_id = yandex_vpc_network.foo.id
v4_cidr_blocks = ["10.1.0.0/24"]
}
Schema
Required
cluster_config
(Block List, Min: 1, Max: 1) Configuration of the MongoDB subcluster. (see below for nested schema)environment
(String) Deployment environment of the MongoDB cluster. Can be eitherPRESTABLE
orPRODUCTION
.host
(Block List, Min: 1) A host of the MongoDB cluster. (see below for nested schema)name
(String) The resource name.network_id
(String) TheVPC Network ID
of subnets which resource attached to.
Optional
cluster_id
(String) The ID of the cluster.database
(Block Set, Deprecated) A database of the MongoDB cluster. (see below for nested schema)deletion_protection
(Boolean) Thetrue
value means that resource is protected from accidental deletion.description
(String) The resource description.disk_size_autoscaling_mongocfg
(Block List, Max: 1) Disk size autoscaling settings for mongocfg. (see below for nested schema)disk_size_autoscaling_mongod
(Block List, Max: 1) Disk size autoscaling settings for mongod. (see below for nested schema)disk_size_autoscaling_mongoinfra
(Block List, Max: 1) Disk size autoscaling settings for mongoinfra. (see below for nested schema)disk_size_autoscaling_mongos
(Block List, Max: 1) Disk size autoscaling settings for mongos. (see below for nested schema)folder_id
(String) The folder identifier that resource belongs to. If it is not provided, the default providerfolder-id
is used.labels
(Map of String) A set of key/value label pairs which assigned to resource.maintenance_window
(Block List, Max: 1) Maintenance window settings of the MongoDB cluster. (see below for nested schema)resources
(Block List, Max: 1, Deprecated) (DEPRECATED, useresources_*
instead) Resources allocated to hosts of the MongoDB cluster. (see below for nested schema)resources_mongocfg
(Block List, Max: 1) Resources allocated tomongocfg
hosts of the MongoDB cluster. (see below for nested schema)resources_mongod
(Block List, Max: 1) Resources allocated tomongod
hosts of the MongoDB cluster. (see below for nested schema)resources_mongoinfra
(Block List, Max: 1) Resources allocated tomongoinfra
hosts of the MongoDB cluster. (see below for nested schema)resources_mongos
(Block List, Max: 1) Resources allocated tomongos
hosts of the MongoDB cluster. (see below for nested schema)restore
(Block List, Max: 1) The cluster will be created from the specified backup. (see below for nested schema)security_group_ids
(Set of String) The list of security groups applied to resource or their components.timeouts
(Block, Optional) (see below for nested schema)user
(Block Set, Deprecated) A user of the MongoDB cluster. (see below for nested schema)
Read-Only
created_at
(String) The creation timestamp of the resource.health
(String) Aggregated health of the cluster. Can be eitherALIVE
,DEGRADED
,DEAD
orHEALTH_UNKNOWN
. For more information seehealth
field of JSON representation in the official documentation.id
(String) The ID of this resource.sharded
(Boolean) MongoDB Cluster mode enabled/disabled.status
(String) Status of the cluster. Can be eitherCREATING
,STARTING
,RUNNING
,UPDATING
,STOPPING
,STOPPED
,ERROR
orSTATUS_UNKNOWN
. For more information seestatus
field of JSON representation in the official documentation.
cluster_config
Nested Schema for Required:
version
(String) Version of the MongoDB server software. Can be either4.2
,4.4
,4.4-enterprise
,5.0
,5.0-enterprise
,6.0
and6.0-enterprise
.
Optional:
access
(Block List, Max: 1) Access policy to the MongoDB cluster. (see below for nested schema)backup_retain_period_days
(Number) Retain period of automatically created backup in days.backup_window_start
(Block List, Max: 1) Time to start the daily backup, in the UTC timezone. (see below for nested schema)feature_compatibility_version
(String) Feature compatibility version of MongoDB. If not provided version is taken. Can be either6.0
,5.0
,4.4
and4.2
.mongocfg
(Block List, Max: 1) Configuration of the mongocfg service. (see below for nested schema)mongod
(Block List, Max: 1) Configuration of the mongod service. (see below for nested schema)mongos
(Block List, Max: 1) Configuration of the mongos service. (see below for nested schema)performance_diagnostics
(Block List, Max: 1) Performance diagnostics to the MongoDB cluster. (see below for nested schema)
cluster_config.access
Nested Schema for Optional:
data_lens
(Boolean) Allow access for Yandex DataLens.data_transfer
(Boolean) Allow access for DataTransfer.web_sql
(Boolean) Allow access for WebSQL.
cluster_config.backup_window_start
Nested Schema for Optional:
hours
(Number) The hour at which backup will be started.minutes
(Number) The minute at which backup will be started.
cluster_config.mongocfg
Nested Schema for Optional:
net
(Block List, Max: 1) A set of network settings (see the net option). (see below for nested schema)operation_profiling
(Block List, Max: 1) A set of profiling settings (see the operationProfiling option). (see below for nested schema)storage
(Block List, Max: 1) A set of storage settings (see the storage option). (see below for nested schema)
cluster_config.mongocfg.net
Nested Schema for Optional:
max_incoming_connections
(Number) The maximum number of simultaneous connections that host will accept. For more information, see the net.maxIncomingConnections description in the official documentation.
cluster_config.mongocfg.operation_profiling
Nested Schema for Optional:
mode
(String) Specifies which operations should be profiled. The following profiler levels are available: off, slow_op, all. For more information, see the operationProfiling.mode description in the official documentation.slow_op_threshold
(Number) The slow operation time threshold, in milliseconds. Operations that run for longer than this threshold are considered slow. For more information, see the operationProfiling.slowOpThresholdMs description in the official documentation.
cluster_config.mongocfg.storage
Nested Schema for Optional:
wired_tiger
(Block List, Max: 1) The WiredTiger engine settings. (see the storage.wiredTiger option). (see below for nested schema)
cluster_config.mongocfg.storage.wired_tiger
Nested Schema for Optional:
cache_size_gb
(Number) Defines the maximum size of the internal cache that WiredTiger will use for all data. For more information, see the storage.wiredTiger.engineConfig.cacheSizeGB description in the official documentation.
cluster_config.mongod
Nested Schema for Optional:
audit_log
(Block List, Max: 1) A set of audit log settings (see the auditLog option). Available only in enterprise edition. (see below for nested schema)net
(Block List, Max: 1) A set of network settings (see the net option). (see below for nested schema)operation_profiling
(Block List, Max: 1) A set of profiling settings (see the operationProfiling option). (see below for nested schema)security
(Block List, Max: 1) A set of MongoDB Security settings (see the security option). Available only in enterprise edition. (see below for nested schema)set_parameter
(Block List, Max: 1) A set of MongoDB Server Parameters (see the setParameter option). (see below for nested schema)storage
(Block List, Max: 1) A set of storage settings (see the storage option). (see below for nested schema)
cluster_config.mongod.audit_log
Nested Schema for Optional:
filter
(String) Configuration of the audit log filter in JSON format. For more information see auditLog.filter description in the official documentation. Available only in enterprise edition.runtime_configuration
(Boolean) Specifies if a node allows runtime configuration of audit filters and the auditAuthorizationSuccess variable. For more information see auditLog.runtimeConfiguration description in the official documentation. Available only in enterprise edition.
cluster_config.mongod.net
Nested Schema for Optional:
compressors
(List of String) Specifies the default compressor(s) to use for communication between this mongod or mongos. Accepts array of compressors. Order matters. Available compressors: snappy, zlib, zstd, disabled. To disable network compression, makedisabled
the only value. For more information, see the net.Compression.Compressors description in the official documentation.max_incoming_connections
(Number) The maximum number of simultaneous connections that host will accept. For more information, see the net.maxIncomingConnections description in the official documentation.
cluster_config.mongod.operation_profiling
Nested Schema for Optional:
mode
(String) Specifies which operations should be profiled. The following profiler levels are available: off, slow_op, all. For more information, see the operationProfiling.mode description in the official documentation.slow_op_sample_rate
(Number) The fraction of slow operations that should be profiled or logged. Accepts values between 0 and 1, inclusive. For more information, see the operationProfiling.slowOpSampleRate description in the official documentation.slow_op_threshold
(Number) The slow operation time threshold, in milliseconds. Operations that run for longer than this threshold are considered slow. For more information, see the operationProfiling.slowOpThresholdMs description in the official documentation.
cluster_config.mongod.security
Nested Schema for Optional:
enable_encryption
(Boolean) Enables the encryption for the WiredTiger storage engine. Can be either true or false. For more information see security.enableEncryption description in the official documentation. Available only in enterprise edition.kmip
(Block List, Max: 1) Configuration of the third party key management appliance via the Key Management Interoperability Protocol (KMIP) (see Encryption tutorial ). Requiresenable_encryption
to be true. The structure is documented below. Available only in enterprise edition. (see below for nested schema)
cluster_config.mongod.security.kmip
Nested Schema for Optional:
client_certificate
(String) String containing the client certificate used for authenticating MongoDB to the KMIP server. For more information see security.kmip.clientCertificateFile description in the official documentation.key_identifier
(String) Unique KMIP identifier for an existing key within the KMIP server. For more information see security.kmip.keyIdentifier description in the official documentation.port
(Number) Port number to use to communicate with the KMIP server. Default: 5696 For more information see security.kmip.port description in the official documentation.server_ca
(String) Path to CA File. Used for validating secure client connection to KMIP server. For more information see security.kmip.serverCAFile description in the official documentation.server_name
(String) Hostname or IP address of the KMIP server to connect to. For more information see security.kmip.serverName description in the official documentation.
cluster_config.mongod.set_parameter
Nested Schema for Optional:
audit_authorization_success
(Boolean) Enables the auditing of authorization successes. Can be either true or false. For more information, see the auditAuthorizationSuccess description in the official documentation. Available only in enterprise edition.enable_flow_control
(Boolean) Enables the flow control. Can be either true or false. For more information, see the enableFlowControl description in the official documentation.min_snapshot_history_window_in_seconds
(Number) The minimum time window in seconds for which the storage engine keeps the snapshot history. For more information, see the minSnapshotHistoryWindowInSeconds description in the official documentation.
cluster_config.mongod.storage
Nested Schema for Optional:
journal
(Block List, Max: 1) The durability journal to ensure data files remain valid and recoverable. (see below for nested schema)wired_tiger
(Block List, Max: 1) The WiredTiger engine settings. (see the storage.wiredTiger option). These settings available only onmongod
hosts. (see below for nested schema)
cluster_config.mongod.storage.journal
Nested Schema for Optional:
commit_interval
(Number) The maximum amount of time in milliseconds that the mongod process allows between journal operations. For more information, see the storage.journal.commitIntervalMs description in the official documentation.
cluster_config.mongod.storage.wired_tiger
Nested Schema for Optional:
block_compressor
(String) Specifies the default compression for collection data. You can override this on a per-collection basis when creating collections. Available compressors are: none, snappy, zlib, zstd. This setting available only onmongod
hosts. For more information, see the storage.wiredTiger.collectionConfig.blockCompressor description in the official documentation.cache_size_gb
(Number) Defines the maximum size of the internal cache that WiredTiger will use for all data. For more information, see the storage.wiredTiger.engineConfig.cacheSizeGB description in the official documentation.prefix_compression
(Boolean) Enables or disables prefix compression for index data. Can be either true or false. For more information, see the storage.wiredTiger.indexConfig.prefixCompression description in the official documentation.
cluster_config.mongos
Nested Schema for Optional:
net
(Block List, Max: 1) A set of network settings (see the net option). (see below for nested schema)
cluster_config.mongos.net
Nested Schema for Optional:
compressors
(List of String) Specifies the default compressor(s) to use for communication between this mongod or mongos. Accepts array of compressors. Order matters. Available compressors: snappy, zlib, zstd, disabled. To disable network compression, makedisabled
the only value. For more information, see the net.Compression.Compressors description in the official documentation.max_incoming_connections
(Number) The maximum number of simultaneous connections that host will accept. For more information, see the net.maxIncomingConnections description in the official documentation.
cluster_config.performance_diagnostics
Nested Schema for Optional:
enabled
(Boolean) Enable or disable performance diagnostics.
host
Nested Schema for Required:
subnet_id
(String) The ID of the subnet, to which the host belongs. The subnet must be a part of the network to which the cluster belongs.zone_id
(String) The availability zone where resource is located. If it is not provided, the default provider zone will be used.
Optional:
assign_public_ip
(Boolean) Should this host have assigned public IP assigned. Can be eithertrue
orfalse
.host_parameters
(Block List, Max: 1) The parameters of mongod host in replicaset. (see below for nested schema)role
(String) The role of the cluster (either PRIMARY or SECONDARY).shard_name
(String) The name of the shard to which the host belongs. Only for sharded cluster.type
(String) Type of Mongo daemon which runs on this host (mongod, mongos, mongocfg, mongoinfra). Defaults tomongod
.
Read-Only:
health
(String) The health of the host.name
(String) The fully qualified domain name of the host. Computed on server side.
host.host_parameters
Nested Schema for Optional:
hidden
(Boolean) Should this host be hidden in replicaset. Can be eithertrue
offalse
. For more information see the official documentation .priority
(Number) A floating point number that indicates the relative likelihood of a replica set member to become the primary. For more information see the official documentation .secondary_delay_secs
(Number) The number of secondsbehind
the primary that this replica set member shouldlag
. For more information see the official documentation .tags
(Map of String) A set of key/value pairs to assign for the replica set member. For more information see the official documentation .
database
Nested Schema for Required:
name
(String) The name of the database.
disk_size_autoscaling_mongocfg
Nested Schema for Required:
disk_size_limit
(Number) Limit of disk size after autoscaling (GiB).
Optional:
emergency_usage_threshold
(Number) Immediate autoscaling disk usage (percent).planned_usage_threshold
(Number) Maintenance window autoscaling disk usage (percent).
disk_size_autoscaling_mongod
Nested Schema for Required:
disk_size_limit
(Number) Limit of disk size after autoscaling (GiB).
Optional:
emergency_usage_threshold
(Number) Immediate autoscaling disk usage (percent).planned_usage_threshold
(Number) Maintenance window autoscaling disk usage (percent).
disk_size_autoscaling_mongoinfra
Nested Schema for Required:
disk_size_limit
(Number) Limit of disk size after autoscaling (GiB).
Optional:
emergency_usage_threshold
(Number) Immediate autoscaling disk usage (percent).planned_usage_threshold
(Number) Maintenance window autoscaling disk usage (percent).
disk_size_autoscaling_mongos
Nested Schema for Required:
disk_size_limit
(Number) Limit of disk size after autoscaling (GiB).
Optional:
emergency_usage_threshold
(Number) Immediate autoscaling disk usage (percent).planned_usage_threshold
(Number) Maintenance window autoscaling disk usage (percent).
maintenance_window
Nested Schema for Required:
type
(String) Type of maintenance window. Can be eitherANYTIME
orWEEKLY
. A day and hour of window need to be specified with weekly window.
Optional:
day
(String) Day of week for maintenance window if window type is weekly. Possible values:MON
,TUE
,WED
,THU
,FRI
,SAT
,SUN
.hour
(Number) Hour of day in UTC time zone (1-24) for maintenance window if window type is weekly.
resources
Nested Schema for Required:
disk_size
(Number) Volume of the storage available to a MongoDB host, in gigabytes.disk_type_id
(String) Type of the storage of MongoDB hosts. For more information see the official documentation.resource_preset_id
(String) The ID of the preset for computational resources available to a MongoDB host (CPU, memory etc.). For more information, see the official documentation.
resources_mongocfg
Nested Schema for Required:
disk_size
(Number) Volume of the storage available to a MongoDB host, in gigabytes.disk_type_id
(String) Type of the storage of MongoDB hosts. For more information see the official documentation.resource_preset_id
(String) The ID of the preset for computational resources available to a MongoDB host (CPU, memory etc.). For more information, see the official documentation.
resources_mongod
Nested Schema for Required:
disk_size
(Number) Volume of the storage available to a MongoDB host, in gigabytes.disk_type_id
(String) Type of the storage of MongoDB hosts. For more information see the official documentation.resource_preset_id
(String) The ID of the preset for computational resources available to a MongoDB host (CPU, memory etc.). For more information, see the official documentation.
resources_mongoinfra
Nested Schema for Required:
disk_size
(Number) Volume of the storage available to a MongoDB host, in gigabytes.disk_type_id
(String) Type of the storage of MongoDB hosts. For more information see the official documentation.resource_preset_id
(String) The ID of the preset for computational resources available to a MongoDB host (CPU, memory etc.). For more information, see the official documentation.
resources_mongos
Nested Schema for Required:
disk_size
(Number) Volume of the storage available to a MongoDB host, in gigabytes.disk_type_id
(String) Type of the storage of MongoDB hosts. For more information see the official documentation.resource_preset_id
(String) The ID of the preset for computational resources available to a MongoDB host (CPU, memory etc.). For more information, see the official documentation.
restore
Nested Schema for Required:
backup_id
(String) Backup ID. The cluster will be created from the specified backup. How to get a list of PostgreSQL backups.
Optional:
time
(String) Timestamp of the moment to which the MongoDB cluster should be restored. (Format:2006-01-02T15:04:05
- UTC). When not set, current time is used.
timeouts
Nested Schema for Optional:
create
(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).delete
(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.update
(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
user
Nested Schema for Required:
name
(String) The name of the user.password
(String, Sensitive) The password of the user.
Optional:
permission
(Block Set) Set of permissions granted to the user. (see below for nested schema)
user.permission
Nested Schema for Required:
database_name
(String) The name of the database that the permission grants access to.
Optional:
roles
(List of String) The roles of the user in this database. For more information see the official documentation.
Import
The resource can be imported by using their resource ID
. For getting the resource ID you can use Yandex Cloud Web Console
# terraform import yandex_mdb_mongodb_cluster.<resource Name> <resource Id>
terraform import yandex_mdb_mongodb_cluster.my_cluster ...