The first answer here is a guide on how to create a Cloud SQL IAM user for your Google Platform Cloud SQL instance.
Here is a guide on how to connect after you've created the user.
postgres
user. Using this user we can assign privileges. IAM users are created with zero privileges to database objects.grant connect on database database_name to "username@email.com";
-- Grant usage on current objects in a schema
grant all on SCHEMA schema_name to "username@email.com";
grant all on all TABLES in SCHEMA schema_name to "username@email.com";
grant all on all FUNCTIONS IN SCHEMA schema_name to "username@email.com";
grant all on all PROCEDURES IN SCHEMA schema_name to "username@email.com";
grant all on all ROUTINES IN SCHEMA schema_name to "username@email.com";
grant all on all SEQUENCES IN SCHEMA schema_name to "username@email.com";
-- Grant usage of any newly created objects in the future
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON FUNCTIONS TO "username@email.com";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON ROUTINES TO "username@email.com";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON SEQUENCES TO "username@email.com";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON TABLES TO "username@email.com";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON types TO "username@email.com";
set session authorization "username@email.com";
reset session authorization;