Hello,
I have a question about how users are synchronized to and from the running postgres sql instance.
Background information:
- I notice that GCP has a permission
cloudsql.users.create
, https://cloud.google.com/sql/docs/sqlserver/iam-permissions - I found these articles on IAM users (https://cloud.google.com/sql/docs/postgres/iam-authentication) and built in users (https://cloud.google.com/sql/docs/postgres/users)
My experimentation:
- I used a standard SQL command to add another user, as the
postgres
user, with something likeCREATE USER username WITH PASSWORD 'a strong password here';
- I went into GCP and noticed that it detected that account, it was listed as a user on the site
My conclusions:
- There must be some kind of means for GCP to know that a user has been added to the database even if it’s not done via gcloud
My questions:
- How did GCP know that I added a user to the database using SQL? Does it periodically poll the database for the list of users or something? Or is the version of postgres that Google is running a fork of open source postgres with some kind of hook to notify GCP whenever a user is added?
- Using SQL, is there any way to add a user to postgres as an IAM user instead of a builtin user? Maybe it has some weird rule like it assumes any user with an “@” in the username is a GCP serviceaccount, or something similar to that?
- If a user is added to the cloud SQL server using SQL, and there’s a failover, will Google bring the database back up with the users added through SQL still present, or will it be restarted with just the users that the server was configured with through terraform/gcloud/etc.?
- I’m not sure I understand what the point of the
cloudsql.users.create
permission rule is, if you can just create a user using SQL. Does that permission have any use if it’s so easily bypassed?
Thanks in advance