servercore_dbaas_postgresql_datastore_v1
Creates and manages a PostgreSQL cluster using public API v1. Applicable to PostgreSQL, PostgreSQL for 1C, and PostgreSQL TimescaleDB clusters. For more information about Managed Databases, see the official Servercore documentation for PostgreSQL, PostgreSQL for 1C, and PostgreSQL TimescaleDB.
Example usage
PostgreSQL and PostgreSQL TimescaleDB
resource "servercore_dbaas_postgresql_datastore_v1" "cluster_1" {
name = "cluster-1"
project_id = servercore_project_v2.project_1.id
region = "ru-3"
type_id = data.servercore_dbaas_datastore_type_v1.datastore_type_1.datastore_types[0].id
subnet_id = servercore_subnet_v2.subnet.subnet_id
node_count = 3
flavor {
vcpus = 4
ram = 4096
disk = 32
disk_type = "network-ultra"
}
pooler {
mode = "transaction"
size = 50
}
security_groups = ["796f1f0a-d97d-4a8e-904e-4fd5ef57465c", "b9c2e73d-a6c5-4def-994d-ce85e3ce98d3"]
}
PostgreSQL for 1C
resource "servercore_dbaas_postgresql_datastore_v1" "cluster_1" {
name = "cluster-1"
project_id = servercore_project_v2.project_1.id
region = "ru-3"
type_id = data.servercore_dbaas_datastore_type_v1.datastore_type_1.datastore_types[0].id
subnet_id = servercore_subnet_v2.subnet.subnet_id
node_count = 3
flavor {
vcpus = 4
ram = 4096
disk = 32
disk_type = "network-ultra"
}
security_groups = ["796f1f0a-d97d-4a8e-904e-4fd5ef57465c", "b9c2e73d-a6c5-4def-994d-ce85e3ce98d3"]
}
Argument Reference
-
name— (Required) Cluster name. Changing this creates a new cluster. -
project_id— (Required) Unique identifier of the associated project. Changing this creates a new cluster. Retrieved from the servercore_vpc_project_v2 resource. Learn more about Projects. -
region— (Required) Pool where the database is located, for example,ru-3. Changing this creates a new cluster. Learn more about available pools in the Availability matrix. -
subnet_id— (Required) Unique identifier of the associated subnet. Changing this creates a new cluster. Retrieved from the servercore_vpc_subnet_v2 resource for a public subnet, or from the openstack_networking_subnet_v2 resource of the OpenStack provider for a private subnet. -
type_id— (Required) Unique identifier of the cluster type. Changing this creates a new cluster. Retrieved from the servercore_dbaas_datastore_type_v1 data source. -
node_count— (Required) Number of nodes in the cluster. The available range is from 1 to 6. Learn more about Replication. -
flavor_id— (Optional) Unique identifier of the flavor for the cluster. Can be skipped whenflavoris set. You can retrieve information about available flavors with the servercore_dbaas_flavor_v1 data source. -
flavor— (Optional) Flavor configuration for the cluster. You can retrieve information about available flavors with the servercore_dbaas_flavor_v1 data source. Learn more about available configurations for PostgreSQL, PostgreSQL for 1C, and PostgreSQL TimescaleDB.-
vcpus— (Required) Number of vCPUs. -
ram— (Required) Amount of RAM in MB. -
disk— (Required) Volume size in GB. -
disk_type— (Optional) Volume type. Available values arelocalandnetwork-ultra. The default value islocal.Learn more about volumes for PostgreSQL, PostgreSQL for 1C and PostgreSQL TimescaleDB.
-
-
pooler— (Optional) Configures a connection pooler for the cluster. Applicable to PostgreSQL and PostgreSQL TimescaleDB.-
mode— (Required) Pooling mode. Available values aresession,transaction, andstatement. The default value istransaction.Learn more about pooling modes for PostgreSQL and PostgreSQL TimescaleDB. -
size— (Required) Pool size. The available range is from 1 to 500. The default value is30. Learn more about pool size for PostgreSQL and PostgreSQL TimescaleDB.
-
-
firewall— (Deprecated) Remove this argument as it is no longer in use and will be removed in the next major version of the provider. To manage a list of IP-addresses with access to the cluster, use the servercore_dbaas_firewall_v1 resource. -
restore— (Optional) Restores parameters for the cluster. Changing this creates a new cluster.-
datastore_id— (Optional) Unique identifier of the cluster from which you restore. To get the cluster ID, in the Control panel, go to Cloud Platform ⟶ Managed Databases ⟶ copy the ID under the cluster name. -
target_time— (Optional) Time within seven previous days when you have the cluster state to restore.
-
-
config— (Optional) Configuration parameters for the cluster. You can retrieve information about available configuration parameters with the servercore_dbaas_configuration_parameter_v1 data source. -
floating_ips— (Optional) Assigns public IP addresses to the nodes in the cluster. The network configuration must meet the requirements. Learn more about public IP addresses and the required network configuration.-
master — (Required) Number of public IPs associated with the master. Available values are
0and1. -
replica — (Required) Number of public IPs associated with the replicas. The minimum value is
0. The maximum value must be 1 less than the value of thenode_countargument.
-
-
backup_retention_days— (Optional) Number of days to retain backups. -
logs— (Optional) Name of an existing or a new log group in the Logs service. The name must start with the prefix 's/dbaas/'. It can contain uppercase and lowercase letters, digits and symbols (underscore, hyphen, forward slash, period and hash). The name cannot exceed 512 symbols. For example, s/dbaas/My-first-group. Learn more about logs for PostgreSQL, PostgreSQL for 1C and PostgreSQL TimescaleDB. -
security_groups— (Optional) List of security groups. If no security group UUIDs are specified when creating the cluster, a default security group will be created and its UUID will be assigned automatically. A cluster must have at least one security group. Learn more about security groups for PostgreSQL, PostgreSQL for 1C and PostgreSQL TimescaleDB.
Attributes Reference
-
status— Cluster status. -
connections— DNS addresses to connect to the cluster.
Import
You can import a cluster:
export OS_DOMAIN_NAME=<account_id>
export OS_USERNAME=<username>
export OS_PASSWORD=<password>
export INFRA_PROJECT_ID=<servercore_project_id>
export INFRA_REGION=<servercore_pool>
terraform import servercore_dbaas_mysql_datastore_v1.datastore_1 <datastore_id>
where:
-
<account_id>— Servercore account ID. The account ID is in the top right corner of the Control panel. Learn more about Registration. -
<username>— Name of the service user. To get the name, in the Control panel, go to Identity & Access Management ⟶ User management ⟶ the Service users tab ⟶ copy the name of the required user. Learn more about Service users. -
<password>— Password of the service user. -
<servercore_project_id>— Unique identifier of the associated project. To get the ID, in the Control panel, go to Cloud Platform ⟶ project name ⟶ copy the ID of the required project. Learn more about Projects. -
<servercore_pool>— Pool where the cluster is located, for example,ru-3. To get information about the pool, in the Control panel, go to Cloud Platform ⟶ Managed Databases. The pool is in the Pool column. -
<datastore_id>— Unique identifier of the cluster, for example,b311ce58-2658-46b5-b733-7a0f418703f2. To get the cluster ID, in the Control panel, go to Cloud Platform ⟶ Managed Databases ⟶ copy the ID under the cluster name.