0
votes

I'm trying to authorize a Google App Engine project into Cloud SQL (PostgreSQL). I can't find a way to do it in the 'Authorization' tab in the instance of Cloud SQL. It only asks me to provide an IP address but I'm not sure if we can really get the IP address of App Engine.

Any suggestion on how to authorize an App Engine project in Cloud SQL?

Authorization tab for Cloudsql

2

2 Answers

0
votes
  • If you are using App Engine Standard in the same project than your CloudSQL instance, your app is already authorized to access it.
  • If you are using the Flexible environment or your app is in a different project, then you'll need to authorize the App Engine's service account by adding it to IAM in the CloudSQL's project and give it the appropriate permissions (Cloud SQL Client or Editor role).

You'll find detailed information here.

0
votes

Providing an IP address of the App Engine is indeed not the way to go. You can only provide IP addresses of current instances of your engine which can be killed and replaced by different instances with new addresses at any time.

Try to follow the tutorial on setting up the App Engine closely from the beginning. I attach a link to a resource about Django as it was applicable in my case https://cloud.google.com/python/django/flexible-environment

In order to connect your App Engine to a Cloud SQL instance within one project, you only have to adjust configuration files in your application. In case of Django, your settings.py and app.yaml file have to be correctly configured. Make sure the database host in settings.py is in the following format, ['HOST'] = '/cloudsql/{your-cloudsql-connection-string}' and that app.yaml includes "beta_settings: cloud_sql_instances: {your-cloudsql-connection-string}".

You can refer to the sample code here. Note that Google Cloud platform Git also contains samples for other environments.