This message was deleted.
# general
s
This message was deleted.
b
The only workaround with Pulumi would be to use a DB proxy and connect via the public IP without connecting the instances, but I'd rather avoid it and do things properly...
g
Indeed it seems how to affect the internal cloud SQL proxy from the API is not documented But you can use a vpc connector and connect directly to the private IP, I normally prefer to not use their proxy because although it is more practical it adds a few millisecond, which is not desirable to a very latency sensitive application (our case)
https://cloud.google.com/run/docs/configuring/connecting-vpc#yaml Create the connector on the same region and add the annotation
h
I've done this exact thing, let me review my stack...
the
DatabaseInstance
has a
ConnectionName
output property. You need to set an annotation in the cloud run service's
Template.Metadata.Annotations
with a key of
<http://run.googleapis.com/cloudsql-instances|run.googleapis.com/cloudsql-instances>
and a value of that
ConnectionName
property from the database instance. Then (i assume) you'll also need to pass a connection string to your app. In my case, I'm using Postgres, so my app's connection string looks like this (params in curly braces):
Host=/cloudsql/{dbStack.CloudSqlConnectionName};Username={dbStack.Username};Password={dbStack.Password};
.
g
I guessed it would be something on that line. But I haven't found the annotation on the docs. I was about to look into the gcloud source to see how the flag affects the resource
h
I used the terraform docs to figure out how to set up the cloud sql instance annotation: https://www.terraform.io/docs/providers/google/r/cloud_run_service.html
b
Thanks @green-school-95910 and @hallowed-rain-9096, I'm going to give it a try today
@hallowed-rain-9096 the annotation following terraform example worked! Thanks 🙂
🎉 1
h
great news! glad that helped