Vault database backend - postgres using a socket

Greetings,

I am currently using unix sockets to connect to cloudsql mysql instances via vault, which looks like the following:

connection_url = "username:password@unix(/cloudsql/project:region:instance_name)/"

I would like utilize socket connections to the cloudsql postgres instances as well. Unfortunately I have having a little trouble translating what I think would be an acceptable connection_url for postgres.

I am looking at the connection info here, which is using the database/sql library. Per the docs on database/sql, they reference the following set of SQLDrivers here.

Based on the documentation of the sql drivers for postgres, it would seem like the following connection_url should work:

connection_url = "postgresql://user:pass@postgres?host=/cloudsql/project:region:instance_name?port=5432"

I’ve tried a few different iterations of the above, but cannot land on something that works.

Does anyone have any experience using a socket in the connection_url of the vault database backend for postgres?

I’ve figured this out - the following connection string works with vault, utilizing the postgres db plugin with a socket:

connection_url = "dbname=postgres user=<user> password=<password> host=/cloudsql/project:region:instance_name port=5432"

I pull the above from the following code.

1 Like