Closed 1lann closed 1 year ago
I've encountered this today too, thanks for the options
parameter hint. I agree the proxy endpoint should be added to the API/provider.
The options parameter seems to be supported in my case, so crafting the url is something like postgresql://${cockroach_sql_user.db.name}:${cockroach_sql_user.db.password}@${cockroach_cluster.db.regions[0].sql_dns}:26257/defaultdb?sslmode=verify-full&options=${urlencode("--cluster=${cockroach_cluster.db.serverless.routing_id}")}
Hey, thanks for bringing this up. I'm pleased to announce the addition of a cockroach_connection_string
datasource in 0.4.1! You should see the tenant ID correctly included in the server URL.
There's also a cockroach_cluster_cert
data source, but that's more relevant for dedicated clusters.
I can't seem to figure out a way to construct the connection URL for a serverless cluster from a
cockroach_cluster
resource. There's thesql_dns
field of a region, but that only provides an endpoint likefree-tier.gcp-us-central1.cockroachlabs.cloud
, which lacks the tenant routing ID, and is not usable to determine the proxy endpoint which looks liketenant-name-1234.5xj.cockroachlabs.cloud
.Although I could technically use the
options
DSN parameter and pass the routing ID via thecluster
option, this is inconvenient as it's not supported by configuration in some applications.This might be a shortcoming of the Cockroach Cloud API as well as I don't see it exposed there either.
It would be nice if this could be added to the provider, and for the data source as well.