0

I am trying to grant a service account with - in postgres. Google Cloud service accounts are setup like user-action@project-environment.

so far I tried:

ALTER USER '[email protected]' WITH REPLICATION;
ALTER USER "[email protected]" WITH REPLICATION;
ALTER USER [email protected] WITH REPLICATION;

Not sure what the solution is.

4
  • 1
    1) What are the error messages you get? 2) Works here on community edition Postgres. 3) This is probably a question for Google support as Cloud SQL != Postgres community edition. Commented Mar 19 at 18:31
  • @LukaszSzozda Backticks are not allowed in PostgreSQL, it's not clear why you mentioned this. The double quotes " work fine in PostgreSQL: postgresql.org/docs/current/… Commented Mar 19 at 19:32
  • I tried the back-tick as well. that did not work. it is possible it is a GCP thing. I don't have regular postgresql setup. Commented Mar 19 at 21:39
  • Please explain the problem, like "CloudSQL Postgres ALTER USER name with "-" returns error xyz. Commented Mar 20 at 14:56

1 Answer 1

1

For Cloud SQL Postgres IAM database authentication, IAM service account database users are created without the .gserviceaccount.com suffix.

You can find this mentioned here in the official docs:

  • For an IAM user, the username is the full email address of the user. For a service account, this is the service account's email without the .gserviceaccount.com domain suffix.

So in the case above you would use:

ALTER USER "[email protected]" WITH REPLICATION;
Sign up to request clarification or add additional context in comments.

5 Comments

Are you sure the single quote ' is the right one? This won't work in PostgreSQL, you would need the double quote "
I don't think that's the issue here. here is the error: Details: pq: syntax error at or near "'[email protected]'"
@FrankHeikens whoops thanks for catching that, I have updated my answer to use double quotes.
@WinstonKyu please try now with double quotes, i have updated the answer
with the double quotes, it worked. thank you so much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.