terraform-provider-postgresql
terraform-provider-postgresql copied to clipboard
Specify multiple hosts in provider configuration for cluster provisionig
for cluster-based Postgres instance lib/pq supports master discovery through specifying multiple hosts in the connection string. For example, to connect to my instance with psql I use the following command
psql "host=host1.mydomain,host2.mydomain \
port=6432 \
sslmode=verify-full \
dbname=postgres \
user=my_user \
target_session_attrs=read-write"
psql automatically detects the current master and connects to it, however this does not work with the provider
Terraform Configuration Files
provider "postgresql" {
host = "host1.mydomian,host2.mydomain"
port = 6432
database = "postgres"
username = "my_user"
superuser = false
password = var.password
sslmode = "verify-full"
connect_timeout = 15
}
when creating resources with such configuration, I get the following error
Error: error detecting capabilities: error PostgreSQL version: dial tcp: lookup host1.mydomain,host2.mydomain: no such host
Note that the configuration works as intended if I manually find the master and only specify one host.