Updating PostgreSQL cluster settings
After creating a cluster, you can:
-
Configure servers according to the PostgreSQL documentation
. -
Move a cluster to another folder.
Learn more about other cluster updates:
Changing the host class
Note
Some PostgreSQL settings depend on the selected host class.
When changing the host class:
- Your single-host cluster will be unavailable for a few minutes with database connections terminated.
- Your multi-host cluster will get a new master host. Its hosts will be stopped and updated one by one. Once stopped, a host will be unavailable for a few minutes.
- Using a special FQDN does not guarantee a stable database connection: user sessions may be terminated.
We recommend changing the host class only when the cluster has no active workload.
- Go to the folder page and select Managed Service for PostgreSQL.
- Select the cluster and click
Edit in the top panel. - Under Host class, select the required class for the PostgreSQL hosts.
- Click Save changes.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change the host class for the cluster:
-
View a description of the update cluster CLI command:
yc managed-postgresql cluster update --help
-
Request a list of available host classes (the
ZONE IDS
column specifies the availability zones where you can select the appropriate class):yc managed-postgresql resource-preset list
+-----------+--------------------------------+-------+----------+ | ID | ZONE IDS | CORES | MEMORY | +-----------+--------------------------------+-------+----------+ | s1.micro | ru-central1-a, ru-central1-b, | 2 | 8.0 GB | | | ru-central1-d | | | | ... | +-----------+--------------------------------+-------+----------+
-
Specify the class in the update cluster command:
yc managed-postgresql cluster update <cluster_name_or_ID> \ --resource-preset <host_class_ID>
Managed Service for PostgreSQL will run the update host class command for the cluster.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about how to create this file, see Creating clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation
. -
In the Managed Service for PostgreSQL cluster description, change the
resource_preset_id
attribute value underconfig.resources
:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... config { resources { resource_preset_id = "<host_class>" ... } } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Time limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Editing a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
To change the class of cluster hosts, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - Host class ID in the
configSpec.resources.resourcePresetId
parameter. To request a list of supported values, use the list method for theResourcePreset
resources. - List of settings to update (in this case,
configSpec.resources.resourcePresetId
) in theupdateMask
parameter.
Warning
This API method overrides all parameters of the object being modified that were not explicitly passed in the request to the default values. To avoid this, list the settings you want to change in the updateMask
parameter (one line separated by commas).
Changing PostgreSQL settings
You can change the DBMS settings of the hosts in your cluster.
Warning
- You cannot change PostgreSQL settings using SQL commands.
- Some PostgreSQL settings depend on the selected host class or storage size.
- Go to the folder page and select Managed Service for PostgreSQL.
- Select the cluster and click
Edit in the top panel. - Change the PostgreSQL settings by clicking Settings under DBMS settings.
- Click Save.
- Click Save changes.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To update the PostgreSQL settings:
-
View the full list of settings specified for the cluster:
yc managed-postgresql cluster get <cluster_name_or_ID> --full
-
View a description of the update cluster configuration CLI command:
yc managed-postgresql cluster update-config --help
-
Set the required parameter values:
All supported parameters are listed in the request format for the update method, in the
postgresqlConfig_<PostgreSQL_version>
field. To specify a parameter name in the CLI call, convert the name fromlowerCamelCase
tosnake_case
. For example, themaxPreparedTransactions
parameter from an API call should be converted tomax_prepared_transactions
for the CLI command:yc managed-postgresql cluster update-config <cluster_name_or_ID> \ --set <name_of_parameter_1>=<value_1>,<name_of_parameter_2>=<value_2>,...
Managed Service for PostgreSQL runs the update cluster settings operation.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about how to create this file, see Creating clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation
. -
In the Managed Service for PostgreSQL cluster description, change the values of the parameters under
config.postgresql_config
. If there is no such section, create one.resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... config { ... postgresql_config = { max_connections = <maximum_number_of_connections> enable_parallel_hash = <true_or_false> vacuum_cleanup_index_scale_factor = <number_from_0_to_1> ... } } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Time limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Editing a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
To change PostgreSQL server settings, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - Required setting values in the
configSpec.postgresqlConfig_<PostgreSQL_version>
parameter. - List of settings to update, in the
updateMask
parameter.
Warning
This API method overrides all parameters of the object being modified that were not explicitly passed in the request to the default values. To avoid this, list the settings you want to change in the updateMask
parameter (one line separated by commas).
Changing additional cluster settings
-
Go to the folder page and select Managed Service for PostgreSQL.
-
Select the cluster and click
Edit in the top panel. -
Change additional cluster settings:
-
Backup start time (UTC): Time interval during which the cluster backup starts. Time is specified in 24-hour UTC format. The default time is
22:00 - 23:00
UTC. -
Retention period for automatic backups, days: Retention period for automatic backups. If an automatic backup expires, it is deleted. The default is 7 days. For more information, see Backups.
Changing the retention period affects both new automatic backups and existing backups. For example, the initial retention period was 7 days. The remaining lifetime for a backup with this period is 1 day. When the retention period increases to 9 days, the remaining lifetime for this backup is 3 days.
Automatic cluster backups are stored for a specified number of days whereas manually created ones are stored indefinitely. After a cluster is deleted, all backups persist for 7 days.
-
Maintenance window: Maintenance window settings:
- To enable maintenance at any time, select arbitrary (default).
- To specify the preferred maintenance start time, select by schedule and specify the desired day of the week and UTC hour. For example, you can choose a time when the cluster is least loaded.
Maintenance operations are carried out both on enabled and disabled clusters. They may include updating the DBMS, applying patches, and so on.
-
DataLens access: This option allows you to analyze cluster data in Yandex DataLens.
-
WebSQL access: Enables you to run SQL queries against cluster databases from the Yandex Cloud management console using Yandex WebSQL.
-
Serverless access: Enable this option to allow cluster access from Yandex Cloud Functions. For more information about setting up access, see the Cloud Functions documentation.
-
Statistics sampling: Allows you to use the Performance diagnostics tool in a cluster. If this option is enabled, also set the Sessions sampling interval and Statements sampling interval using the sliders. Both are measured in seconds.
This feature is at the Preview stage.
-
Autofailover: Enable this option so that when the master host changes, the replication source for every replica host is automatically switched over to the new master host. To learn more, see Replication.
If the master host is deleted, a new master will be selected automatically regardless of the value of this option.
Alert
If the Autofailover option is disabled, run the selection of a new master or assign this role to one of the replicas manually if the master host fails.
-
Pooling mode: Select one of the connection pooler modes.
-
Deletion protection: Manages protection of the cluster, its databases, and users against accidental deletion.
By default, the parameter inherits its value from the cluster when creating users and databases. You can also set the value manually; for more information, see the User management and Database management sections.
If the parameter is changed on a running cluster, only users and databases with the Same as cluster protection will inherit the new value.
Enabled deletion protection will not prevent a manual connection with the purpose to delete database contents.
-
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change additional cluster settings:
-
View a description of the update cluster CLI command:
yc managed-postgresql cluster update --help
-
Run the following command with a list of settings to update:
yc managed-postgresql cluster update <cluster_name_or_ID> \ --backup-window-start <backup_start_time> \ --datalens-access=<true_or_false> \ --maintenance-window type=<maintenance_type>,` `day=<day_of_week>,` `hour=<hour> \ --websql-access=<true_or_false> \ --deletion-protection=<deletion_protection> \ --connection-pooling-mode=<connection_pooler_mode> \ --serverless-access=<true_or_false> \ --yandexquery-access=<access_through_Query> \ --performance-diagnostics enabled=<true_or_false>,` `sessions-sampling-interval=<session_sampling_interval>,` `statements-sampling-interval=<statement_sampling_interval>
You can change the following settings:
--backup-window-start
: The cluster backup start time, set in UTC formatHH:MM:SS
. If the time is not set, the backup will start at 22:00 UTC.
-
--datalens-access
: Enables DataLens access. The default value isfalse
. For more information on setting up a connection, see Connecting to a cluster from DataLens. -
--maintenance-window
: Maintenance window settings (including for disabled clusters), wheretype
is the maintenance type:anytime
(default): Any time.weekly
: On a schedule. If setting this value, specify the day of week and the hour:day
: Day of week inDDD
format:MON
,TUE
,WED
,THU
,FRI
,SAT
, orSUN
.hour
: Hour (UTC) inHH
format:1
to24
.
-
--websql-access
: Enables you to run SQL queries to cluster databases from the Yandex Cloud management console using Yandex WebSQL. The default value isfalse
. -
--serverless-access
: Enables cluster access from Yandex Cloud Functions. The default value isfalse
. For more information about setting up access, see the Cloud Functions documentation. -
--yandexquery-access
: Enables cluster access from Yandex Query. This feature is at the Preview stage and available upon request. -
--autofailover
manages automatic master change setup. To learn more, see Replication. The default value istrue
. -
--connection-pooling-mode
: Specifies the connection pooler mode (SESSION
,TRANSACTION
, orSTATEMENT
). -
--deletion-protection
: Protection of the cluster, its databases, and users against accidental deletion,true
orfalse
.By default, the parameter inherits its value from the cluster when creating users and databases. You can also set the value manually; for more information, see the User management and Database management sections.
If the parameter is changed on a running cluster, only users and databases with the Same as cluster protection will inherit the new value.
Enabled deletion protection will not prevent a manual connection with the purpose to delete database contents.
-
--performance-diagnostics
: Statistics collection settings:enabled
:true
value enables statistics collection. The default value isfalse
.sessions-sampling-interval
: Session sampling interval, seconds. Acceptable values are between1
and86400
.statements-sampling-interval
: Statement sampling interval, seconds. Acceptable values are between60
and86400
.
You can retrieve the cluster name with a list of clusters in the folder.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about how to create this file, see Creating clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation
. -
To change the backup start time, add a block named
config.backup_window_start
to the Managed Service for PostgreSQL cluster description.resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... config { backup_window_start { hours = <hour_of_backup_start_time> minutes = <minute_of_backup_start_time> } ... } }
-
To enable access from Yandex DataLens and allow execution of SQL queries from the management console using Yandex WebSQL, change the values of the appropriate fields in the
config.access
section:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... config { access { data_lens = <access_from_DataLens> web_sql = <execution_of_SQL_queries_from_management_console> ... } ... }
Where:
data_lens
: Access from DataLens,true
orfalse
.web_sql
: Execution of SQL queries from the management console using Yandex WebSQL:true
orfalse
.
-
To change the connection pooler mode, add the
config.pooler_config
section to the Managed Service for PostgreSQL cluster description:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... config { pooler_config { pool_discard = <Odyssey_parameter> pooling_mode = "<pooling_mode>" } ... } }
Where:
pool_discard
: Odysseypool_discard
parameter,true
orfalse
.pooling_mode
: Pooling mode:SESSION
,TRANSACTION
, orSTATEMENT
.
-
To set up the maintenance window (for disabled clusters as well), add the
maintenance_window
section to the cluster description:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... maintenance_window { type = <maintenance_type> day = <day_of_week> hour = <hour> } ... }
Where:
type
: Maintenance type. The possible values include:anytime
: Anytime.weekly
: By schedule.
day
: Day of the week for theweekly
type inDDD
format, e.g.,MON
.hour
: Hour of the day for theweekly
type in theHH
format, e.g.,21
.
-
To set up statistics collection, to the
config
section, add theperformance_diagnostics
section:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... config { ... performance_diagnostics { enabled = <enables statistics collection: true or false> sessions_sampling_interval = <sessions sampling interval> statements_sampling_interval = <statements sampling interval> } ... } ... }
Where:
enabled
: Enable statistics collection,true
orfalse
.sessions_sampling_interval
: Session sampling interval, from1
to86400
seconds.statements_sampling_interval
: Statement sampling interval, from60
to86400
seconds.
-
To enable protection of the cluster, its databases, and users against accidental deletion, add the
deletion_protection
field set totrue
to your cluster description:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... deletion_protection = <deletion_protection> }
Where
deletion_protection
is the protection of the cluster, its databases, and users against deletion. It may take either thetrue
orfalse
value.By default, the parameter inherits its value from the cluster when creating users and databases. You can also set the value manually; for more information, see the User management and Database management sections.
If the parameter is changed on a running cluster, only users and databases with the Same as cluster protection will inherit the new value.
Enabled deletion protection will not prevent a manual connection with the purpose to delete database contents.
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Time limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Editing a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
To change additional cluster settings, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
-
Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. -
Settings for access from other services in the
configSpec.access
parameter. -
Backup window settings in the
configSpec.backupWindowStart
parameter. -
Connection pooler mode in the
configSpec.poolerConfig.poolingMode
parameter. -
Maintenance window settings (including for disabled clusters) in the
maintenanceWindow
parameter. -
Settings for protection of the cluster, its databases, and users against deletion in the
deletionProtection
parameter:true
orfalse
.By default, the parameter inherits its value from the cluster when creating users and databases. You can also set the value manually; for more information, see the User management and Database management sections.
If the parameter is changed on a running cluster, only users and databases with the Same as cluster protection will inherit the new value.
Enabled deletion protection will not prevent a manual connection with the purpose to delete database contents.
-
List of cluster configuration fields to update in the
UpdateMask
parameter.
Warning
This API method overrides all parameters of the object being modified that were not explicitly passed in the request to the default values. To avoid this, list the settings you want to change in the updateMask
parameter (one line separated by commas).
To allow cluster access from Yandex Cloud Functions, set true
for the configSpec.access.serverless
parameter. For more information about setting up access, see the Cloud Functions documentation.
To allow cluster access from Yandex Query, set true
for the configSpec.access.yandexQuery
parameter. This feature is at the Preview stage and available upon request.
To enable statistics collection:
- Pass the
true
value in theconfig.performanceDiagnostics.enabled
parameter. - Pass the sessions sampling interval in the
config.performanceDiagnostics.sessionsSamplingInterval
parameter. - Pass the statements sampling interval in the
config.performanceDiagnostics.statementsSamplingInterval
parameter.
Acceptable parameter values:
config.performanceDiagnostics.sessionsSamplingInterval
: From1
to86400
seconds.config.performanceDiagnostics.statementsSamplingInterval
: From60
to86400
seconds.
Manually switching the master
In a fault-tolerant Managed Service for PostgreSQL cluster with multiple hosts, you can switch the master role from the current master host to one of the replicas. After this operation, the current master host becomes the replica host of the new master.
Specifics of switching master hosts in Managed Service for PostgreSQL
- You cannot switch the master host to a replica for which the source of the replication stream is explicitly given.
- If you do not specify the replica host name explicitly, the master host will switch to one of the quorum replicas.
To learn more, see Replication.
To switch the master:
- Go to the folder page and select Managed Service for PostgreSQL.
- Click the cluster name and select the
Hosts tab. - Click
Switch master.- To switch the master to one of the quorum replicas, leave the Choose master host automatically option enabled.
- To switch the master to a specific replica, disable the Choose master host automatically option and then select the required replica from the drop-down list.
- Click Switch.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
Run this command:
yc managed-postgresql cluster start-failover <cluster_name_or_ID> \
--host <replica_host_name>
You can request the replica host name with a list of cluster hosts and the cluster name with a list of clusters in the folder.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about how to create this file, see Creating clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation
. -
In the
host_master_name
parameter, specify the name of the replica host to switch to.resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... host_master_name = "<replica_host_name>" }
Where
host_master_name
is the name of the replica host, i.e., thename
attribute of the appropriatehost
block. -
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Time limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Editing a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
To switch the master host, use the startFailover REST API method for the Cluster resource or the ClusterService/StartFailover gRPC API call and provide the following in the request:
- ID of the cluster where you want to switch the master, in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - (Optional) In the
hostName
parameter, the name of the replica host to switch to. To find out the name, get a list of hosts in the cluster.
Moving a cluster
- Go to the folder page and select Managed Service for PostgreSQL.
- Click
to the right of the cluster you want to move. - Select Move.
- Select a folder you want to move the cluster to.
- Click Move.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To move a cluster:
-
View a description of the CLI move cluster command:
yc managed-postgresql cluster move --help
-
Specify the destination folder in the move cluster command:
yc managed-postgresql cluster move <cluster_ID> \ --destination-folder-name=<destination_folder_name>
You can get the cluster ID with a list of clusters in the folder.
To move a cluster, use the move REST API method for the Cluster resource or the ClusterService/Move gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - ID of the destination folder in the
destinationFolderId
parameter.
After the cluster is moved, it will continue using the cloud network from the source folder. If you want to host the cluster in a different cloud network, use the restore from a backup feature and specify the required network for the cluster backup.
To move a cluster to a different availability zone, follow this guide. You will thus move the cluster hosts.
Changing security groups
- Go to the folder page and select Managed Service for PostgreSQL.
- Select the cluster and click
Edit in the top panel. - Under Network settings, select security groups for cluster network traffic.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To edit the list of security groups for your cluster:
-
View a description of the update cluster CLI command:
yc managed-postgresql cluster update --help
-
Specify the security groups in the update cluster command:
yc managed-postgresql cluster update <cluster_name_or_ID> \ --security-group-ids <list_of_security_group_IDs>
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about how to create this file, see Creating clusters.
For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation
. -
Change the value of the
security_group_ids
parameter in the cluster description:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... security_group_ids = [ <list_of_security_group_IDs> ] }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Time limits
A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:
- Creating a cluster, including restoring from a backup: 30 minutes.
- Editing a cluster: 60 minutes.
- Deleting a cluster: 15 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?Add the
timeouts
block to the cluster description, for example:resource "yandex_mdb_postgresql_cluster" "<cluster_name>" { ... timeouts { create = "1h30m" # 1 hour 30 minutes update = "2h" # 2 hours delete = "30m" # 30 minutes } }
-
To edit the list of cluster security groups, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - List of security group IDs in the
securityGroupIds
parameter. - List of settings to update (in this case,
securityGroupIds
) in theupdateMask
parameter.
Warning
This API method overrides all parameters of the object being modified that were not explicitly passed in the request to the default values. To avoid this, list the settings you want to change in the updateMask
parameter (one line separated by commas).
Warning
You may need to additionally set up security groups to connect to the cluster.