We're using Google Cloud Run with a java app to store data in Cloud Sql Postgres. We need to connect to external services using a static IP.
We are connecting to the database using the example code provided in [the documentation](
https://cloud.google.com/sql/docs/postgres/connect-run), with the following connection string: jdbc:postgresql:///<DB_NAME>?unixSocketPath=</PATH/TO/UNIX/SOCKET>&cloudSqlInstance=<CLOUD_SQL_CONNECTION_NAME>&
// socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=<DB_USER>&password=<DB_PASS>. In the Cloud Run service we pointed the Cloud SQL connections to the database. This works well.
We're running a test service that shows the external IP, and again, this shows the static external IP.
The problem is that now the connection to the database does not work anymore.
To fix this, we removed the unixSocketPath from the database connection string, resulting in jdbc:postgresql:///<DB_NAME>?cloudSqlInstance=<CLOUD_SQL_CONNECTION_NAME>&
// socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=<DB_USER>&password=<DB_PASS>.
Now the following problem pops up, once in a while:
Failed to create ephemeral certificate for the Cloud SQL instance.
What are we missing? Is there a way to connect to the outside world using a static ip, and have a reliable connection to Cloud Sql?