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 "[email protected]";
-- Grant usage on current objects in a schema
grant all on SCHEMA schema_name to "[email protected]";
grant all on all TABLES in SCHEMA schema_name to "[email protected]";
grant all on all FUNCTIONS IN SCHEMA schema_name to "[email protected]";
grant all on all PROCEDURES IN SCHEMA schema_name to "[email protected]";
grant all on all ROUTINES IN SCHEMA schema_name to "[email protected]";
grant all on all SEQUENCES IN SCHEMA schema_name to "[email protected]";
-- Grant usage of any newly created objects in the future
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON FUNCTIONS TO "[email protected]";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON ROUTINES TO "[email protected]";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON SEQUENCES TO "[email protected]";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON TABLES TO "[email protected]";
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT all ON types TO "[email protected]";
set session authorization "[email protected]";
reset session authorization;