Getting notAuthorized error with cloud_sql_proxy locally
In my case the problem was that the service account didn't have the correct role. You should at least set it to Editor.
TL;DR: If your error log contains Error during createEphemeral..
, please read on.
Solution that works for me is from Github Cloud-SQL-Proxy Issue Tracker.
It seems that you may have encountered a bug in backend that is triggered when there is an old service account with the same name. Follow the steps below to solve your issue:
- Go to the Cloud Project IAM page (Left Menu > IAM & Admin > IAM)
- Look for the row with the robot account that is having the issue.
- It should say "Cloud SQL Client" on the role column.
- Click on it to open the dropdown
- Click on the 'Cloud SQL Client' role that is checked to uncheck it.
- Click the blue save button above.
- Verify that the service account is removed from the IAM page.
- Click the Add button above in the same page.
- Enter the service account email address and select the Cloud SQL Client role
- Click Add
- The service account should appear again in the the list.
Credits to Chees, but points are mine :P. Hope it solves your issue.