using mysql socket failes within google cloud run....
# help
p
using mysql socket failes within google cloud run. 1: is this dsn allowed? / are socket connections are supported by cerbos "${DATABASE_USER}:${DATABASE_PASSWORD}@tcp(localhost:3307)/${DATABASE_NAME}?socket=${DATABASE_SOCKET}" 2: i had to escape the socket-path as %2Fcloudsql%2F<sql-connection-name> instead of /cloudsql/<sql-connection-name> Is this the right escape-method? what should be used here? i also tried $2F and //
c
Yeah, it's a URL so special characters like
/
have to be percent encoded
p
instead of the app-engine custom cloud sql port 3307 the default port 3306 is used. i changes that, but still get: cerbos: error: failed to create store: failed to connect to database: dial tcp 127.0.0.13306 connect: connection refused
current dsn is: ${DATABASE_USER}:${DATABASE_PASSWORD}@tcp(localhost:3306)/${DATABASE_NAME}?socket=%2Fcloudsql%2Fprojectregioninstance
c
According to https://cloud.google.com/sql/docs/mysql/connect-run#go, the URL to connect with a socket is:
${DATABASE_USER}:${DATABASE_PASSWORD}@unix(${DATABASE_SOCKET})/${DATABASE_NAME}
p
that worked, ver much thank you
may create a section within the documentation for that? I guess for google cloud users this could be a huge benefit 🙂
c
Will add an example of connecting with a Unix socket 🙂
p
do i have to create the database definition myself? the database is after use still empty and I get the following error while quering the admin api: could not get policy ids
c
Yes, you have to create the schema yourself. Otherwise Cerbos would have to run with admin privileges, which is not good for security.
p
maybe a console hint => the schema does not exists => create it manualy, which link to the docs could help here for future setups 🙂 hope noone feels bothered by my suggestions😅
but I guess, you may reconsidder this aproach for future updates it could be necessary to rely on database-migrations f.ex. by prisma or an other library to implement changes in feature versions
c
The documentation does say that you have to create the schema manually 🙂 We do have an open task to detect and warn about the schema not being there.
p
perfect. thank you for your time