Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Terraform in Yandex Cloud
  • Getting started
  • Solution library
    • Overview
    • Release notes
          • mdb_mysql_cluster
          • mdb_mysql_cluster_v2
          • mdb_mysql_database
          • mdb_mysql_user

In this article:

  • Example Usage
  • Schema
  • Required
  • Optional
  • Read-Only
  • Nested Schema for hosts
  • Nested Schema for access
  • Nested Schema for backup_window_start
  • Nested Schema for disk_size_autoscaling
  • Nested Schema for maintenance_window
  • Nested Schema for performance_diagnostics
  • Nested Schema for resources
  • Nested Schema for restore
  • Nested Schema for timeouts
  • Import
  1. Terraform reference
  2. Resources
  3. Managed Service for MySQL
  4. Resources
  5. mdb_mysql_cluster_v2

yandex_mdb_mysql_cluster_v2 (Resource)

Written by
Yandex Cloud
Updated at September 11, 2025
  • Example Usage
  • Schema
    • Required
    • Optional
    • Read-Only
    • Nested Schema for hosts
    • Nested Schema for access
    • Nested Schema for backup_window_start
    • Nested Schema for disk_size_autoscaling
    • Nested Schema for maintenance_window
    • Nested Schema for performance_diagnostics
    • Nested Schema for resources
    • Nested Schema for restore
    • Nested Schema for timeouts
  • Import

Manages a MySQL cluster within the Yandex Cloud. For more information, see the official documentation. How to connect to the DB. To connect, use port 6432. The port number is not configurable.

Example UsageExample Usage

//
// Create a new MDB MySQL Cluster (v2).
//

resource "yandex_mdb_mysql_cluster_v2" "cluster" {
  name        = "mysql-cluster"
  description = "MySQL Test Cluster"
  network_id  = yandex_vpc_network.mdb-pg-test-net.id
  environment = "PRODUCTION"

  labels = {
    "key1" = "value1"
    "key2" = "value2"
    "key3" = "value3"
  }

  hosts = {
    "host" = {
      zone             = "ru-central1-a"
      subnet_id        = yandex_vpc_subnet.mdb-pg-test-subnet-a.id
      assign_public_ip = false
    }
  }

  version = "8.0"
  resources {
    resource_preset_id = "b1.medium"
    disk_type_id       = "network-ssd"
    disk_size          = 10
  }

  performance_diagnostics = {
    sessions_sampling_interval   = 60
    statements_sampling_interval = 600
  }

  access = {
    web_sql       = true
    data_transfer = true
    data_lens     = true
  }

  maintenance_window = {
    type = "WEEKLY"
    day  = "MON"
    hour = 3
  }

  backup_window_start = {
    hours   = 5
    minutes = 5
  }

  backup_retain_period_days = 8
  deletion_protection       = true
}

// Auxiliary resources
resource "yandex_vpc_network" "test-net" {}

resource "yandex_vpc_subnet" "test-subnet" {
  zone           = "ru-central1-a"
  network_id     = yandex_vpc_network.mdb-pg-test-net.id
  v4_cidr_blocks = ["10.1.0.0/24"]
}

resource "yandex_vpc_security_group" "test-sgroup" {
  description = "Test security group"
  network_id  = yandex_vpc_network.mdb-pg-test-net.id
}

SchemaSchema

RequiredRequired

  • environment (String) Deployment environment of the MySQL cluster.
  • hosts (Attributes Map) A host configuration of the MySQL cluster. (see below for nested schema)
  • name (String) Name of the MySQL cluster. Provided by the client when the cluster is created.
  • network_id (String) The VPC Network ID of subnets which resource attached to.
  • version (String) Version of the MySQL cluster.

OptionalOptional

  • access (Attributes) Access policy to the MySQL cluster. (see below for nested schema)
  • backup_retain_period_days (Number) The period in days during which backups are stored.
  • backup_window_start (Attributes) Time to start the daily backup, in the UTC timezone. (see below for nested schema)
  • deletion_protection (Boolean) The true value means that resource is protected from accidental deletion.
  • description (String) Description of the MySQL cluster.
  • disk_encryption_key_id (String) ID of the symmetric encryption key used to encrypt the disk of the cluster.
  • disk_size_autoscaling (Attributes) Cluster disk size autoscaling settings. (see below for nested schema)
  • folder_id (String) The folder identifier that resource belongs to. If it is not provided, the default provider folder-id is used.
  • labels (Map of String) A set of key/value label pairs which assigned to resource.
  • maintenance_window (Attributes) Maintenance policy of the MySQL cluster. (see below for nested schema)
  • mysql_config (Map of String) MySQL cluster config.
  • performance_diagnostics (Attributes) Cluster performance diagnostics settings. The structure is documented below. (see below for nested schema)
  • resources (Block, Optional) Resources allocated to hosts of the MySQL cluster. (see below for nested schema)
  • restore (Attributes) 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 (Attributes) (see below for nested schema)

Read-OnlyRead-Only

  • id (String) The resource identifier.

Nested Schema for Nested Schema for hosts

Required:

  • zone (String) The availability zone where the host is located.

Optional:

  • assign_public_ip (Boolean) Assign a public IP address to the host.
  • replication_source (String) FQDN of the host that is used as a replication source.
  • subnet_id (String) ID of the subnet where the host is located.

Read-Only:

  • fqdn (String) The fully qualified domain name of the host.

Nested Schema for Nested Schema for access

Optional:

  • data_lens (Boolean) Allow access for Yandex DataLens.
  • data_transfer (Boolean) Allow access for DataTransfer
  • web_sql (Boolean) Allow access for SQL queries in the management console

Nested Schema for Nested Schema for backup_window_start

Optional:

  • hours (Number) The hour at which backup will be started (UTC).
  • minutes (Number) The minute at which backup will be started (UTC).

Nested Schema for Nested Schema for disk_size_autoscaling

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).

Nested Schema for Nested Schema for maintenance_window

Optional:

  • day (String) Day of the week (in DDD format). Allowed values: "MON", "TUE", "WED", "THU", "FRI", "SAT","SUN"
  • hour (Number) Hour of the day in UTC (in HH format). Allowed value is between 1 and 24.
  • type (String) Type of maintenance window. Can be either ANYTIME or WEEKLY. A day and hour of window need to be specified with weekly window.

Nested Schema for Nested Schema for performance_diagnostics

Required:

  • sessions_sampling_interval (Number) Interval (in seconds) for pg_stat_activity sampling Acceptable values are 1 to 86400, inclusive.
  • statements_sampling_interval (Number) Interval (in seconds) for pg_stat_statements sampling Acceptable values are 60 to 86400, inclusive.

Optional:

  • enabled (Boolean) Enable performance diagnostics

Nested Schema for Nested Schema for resources

Required:

  • disk_size (Number) Size of the disk in bytes.
  • disk_type_id (String) ID of the disk type that determines the disk performance characteristics.
  • resource_preset_id (String) ID of the resource preset that determines the number of CPU cores and memory size for the host.

Nested Schema for Nested Schema for restore

Required:

  • backup_id (String) Backup ID. The cluster will be created from the specified backup. How to get a list of MySQL backups.

Optional:

  • time (String) Timestamp of the moment to which the MySQL cluster should be restored. (Format: 2006-01-02T15:04:05 - UTC). When not set, current time is used.

Nested Schema for Nested Schema for timeouts

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).

ImportImport

The resource can be imported by using their resource ID. For getting the resource ID you can use Yandex Cloud Web Console or YC CLI.

# terraform import yandex_mdb_postgresql_cluster_v2.<resource Name> <resource Id>
terraform import yandex_mdb_postgresql_cluster_v2.my_v2_cluster ...

Was the article helpful?

Previous
mdb_mysql_cluster
Next
mdb_mysql_database
© 2025 Direct Cursus Technology L.L.C.