yandex_mdb_sqlserver_cluster (Resource)
Статья создана
Обновлена 7 августа 2025 г.
Manages a SQLServer cluster within the Yandex Cloud. For more information, see the official documentation.
Please read Pricing for Managed Service for SQL Server before using SQLServer cluster.
Example usage
//
// Create a new MDB SQL Server Cluster.
//
resource "yandex_mdb_sqlserver_cluster" "my_cluster" {
name = "test"
environment = "PRESTABLE"
network_id = yandex_vpc_network.foo.id
version = "2016sp2std"
resources {
resource_preset_id = "s2.small"
disk_type_id = "network-ssd"
disk_size = 20
}
labels = { test_key : "test_value" }
backup_window_start {
hours = 20
minutes = 30
}
sqlserver_config = {
fill_factor_percent = 49
optimize_for_ad_hoc_workloads = true
}
database {
name = "db_name_a"
}
database {
name = "db_name"
}
database {
name = "db_name_b"
}
user {
name = "bob"
password = "mysecurepassword"
}
user {
name = "alice"
password = "mysecurepassword"
permission {
database_name = "db_name"
roles = ["DDLADMIN"]
}
}
user {
name = "chuck"
password = "mysecurepassword"
permission {
database_name = "db_name_a"
roles = ["OWNER"]
}
permission {
database_name = "db_name"
roles = ["OWNER", "DDLADMIN"]
}
permission {
database_name = "db_name_b"
roles = ["OWNER", "DDLADMIN"]
}
}
host {
zone = "ru-central1-a"
subnet_id = yandex_vpc_subnet.foo.id
}
security_group_ids = [yandex_vpc_security_group.test-sg-x.id]
host_group_ids = ["host_group_1", "host_group_2"]
}
// Auxiliary resources
resource "yandex_vpc_network" "foo" {}
resource "yandex_vpc_subnet" "foo" {
zone = "ru-central1-a"
network_id = yandex_vpc_network.foo.id
v4_cidr_blocks = ["10.5.0.0/24"]
}
resource "yandex_vpc_security_group" "test-sg-x" {
network_id = yandex_vpc_network.foo.id
ingress {
protocol = "ANY"
description = "Allow incoming traffic from members of the same security group"
from_port = 0
to_port = 65535
v4_cidr_blocks = ["0.0.0.0/0"]
}
egress {
protocol = "ANY"
description = "Allow outgoing traffic to members of the same security group"
from_port = 0
to_port = 65535
v4_cidr_blocks = ["0.0.0.0/0"]
}
}
Schema
Required
database(Block List, Min: 1) A database of the SQLServer cluster. (see below for nested schema)environment(String) Deployment environment of the SQLServer cluster. (PRODUCTION, PRESTABLE).host(Block List, Min: 1) A host of the SQLServer cluster. (see below for nested schema)name(String) The resource name.network_id(String) TheVPC Network IDof subnets which resource attached to.resources(Block List, Min: 1, Max: 1) Resources allocated to hosts of the SQLServer cluster. (see below for nested schema)user(Block List, Min: 1) A user of the SQLServer cluster. (see below for nested schema)version(String) Version of the SQLServer cluster. (2016sp2std, 2016sp2ent).
Optional
backup_window_start(Block List, Max: 1) Time to start the daily backup, in the UTC. (see below for nested schema)deletion_protection(Boolean) Thetruevalue means that resource is protected from accidental deletion.description(String) The resource description.folder_id(String) The folder identifier that resource belongs to. If it is not provided, the default providerfolder-idis used.host_group_ids(Set of String) A list of IDs of the host groups hosting VMs of the cluster.labels(Map of String) A set of key/value label pairs which assigned to resource.security_group_ids(Set of String) The list of security groups applied to resource or their components.sqlcollation(String) SQL Collation cluster will be created with. This attribute cannot be changed when cluster is created!sqlserver_config(Map of String) SQLServer cluster config. Detail info inSQLServer configsection.timeouts(Block, Optional) (see below for nested schema)
Read-Only
created_at(String) The creation timestamp of the resource.health(String) Aggregated health of the cluster.id(String) The ID of this resource.status(String) Status of the cluster.
Nested Schema for database
Required:
name(String) The name of the database.
Nested Schema for host
Required:
zone(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) Sets whether the host should get a public IP address on creation. Changing this parameter for an existing host is not supported at the moment.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.
Read-Only:
fqdn(String) The fully qualified domain name of the host.
Nested Schema for resources
Required:
disk_size(Number) Volume of the storage available to a SQLServer host, in gigabytes.disk_type_id(String) Type of the storage of SQLServer hosts.resource_preset_id(String) The ID of the preset for computational resources available to a SQLServer host (CPU, memory etc.). For more information, see the official documentation.
Nested Schema for user
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)
Nested Schema for user.permission
Required:
database_name(String) The name of the database that the permission grants access to.
Optional:
roles(Set of String) List user's roles in the database. Allowed roles:OWNER,SECURITYADMIN,ACCESSADMIN,BACKUPOPERATOR,DDLADMIN,DATAWRITER,DATAREADER,DENYDATAWRITER,DENYDATAREADER.
Nested Schema for backup_window_start
Optional:
hours(Number) The hour at which backup will be started.minutes(Number) The minute at which backup will be started.
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).
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_sqlserver_cluster.<resource Name> <resource Id>
terraform import yandex_mdb_sqlserver_cluster.my_cluster ...