Sunday, October 1, 2017

[google-cloud-sql-discuss] Re: cloud sql proxy -- 403


If possible, can you email me your project ID and the SQL instance name to investigate this issue?



On Sunday, October 1, 2017 at 1:13:40 PM UTC-4, Thibault Bronchain wrote:
Hi guys,

I'm having a 403 issue when trying to use the proxy. I've found a lot of issues about this matter online, but I've tried everything I've found and nothing seemed to work.

My goal is to access the cloud sql instance through kubernetes (google container cloud). As I couldn't make it work, I retried to connect through a gce engine, then my local machine. I always end up with the same issue.


So I activated the API, created a service with cloud sql client and viewer rights (as I read viewer could be needed) and downloaded the file.
I created a user (replacing myinstance1 by my instance name):  gcloud sql users create proxyuser cloudsqlproxy~% --instance=myinstance1
I actually also tried to connect as root, and with a much more permissive service account file, with no more luck.

The problem is always the same. On the proxy:

$./cloud_sql_proxy -instances=myproject:us-central1:myinstance1=tcp:3306 -credential_file=./myserviceaccount.json 
2017/10/01 15:32:51 using credential file for authentication; email=myserviceaccount@myproject.iam.gserviceaccount.com
2017/10/01 15:32:51 Listening on 127.0.0.1:3306 for myproject:us-central1:myinstance1
2017/10/01 15:32:51 Ready for new connections
2017/10/01 15:32:55 New connection for "myproject:us-central1:myinstance1"
2017/10/01 15:33:01 couldn't connect to "myproject:us-central1:myinstance1": ensure that the account has access to "myproject:us-central1:myinstance1" (and make sure there's no typo in that name). Error during createEphemeral for myproject:us-central1:myinstance1: googleapi: Error 403: The client is not authorized to make this request., notAuthorized

and on the client side:

$mysql -u root -p --protocol=TCP --host="127.0.0.1"
Enter password: 
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

$mysql -u proxyuser -p --protocol=TCP --host="127.0.0.1"
Enter password: 
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

$mysql -u root -p --host 127.0.0.1
Enter password: 
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0


... among others.

I have checked a few issues like this one https://github.com/GoogleCloudPlatform/cloudsql-proxy/issues/115 but it doesn't seem to apply to me.

I forgot to precise that I tried to connect to the db using Cloud Shell (by clicking on the link), and it worked fine.

I'm stuck. I am not sure if either I missed something, or if I am hitting a bug.

Thanks a lot to anyone who's willing to help,
Thibault.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/57c69b6f-d182-4e17-b7eb-ef8bf107b661%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment