0
votes

I have a GCP project running Cloud SQL and a Django App inside a Google App Engine Flexible Environment and it works fine. However, when I try to connect to the same Cloud SQL instance from another project it doesn't work since the socket is not being created as specified by the cloud_sql_instances in app.yaml:

runtime: custom
env: flex
automatic_scaling:
  min_num_instances: 1
beta_settings:
    cloud_sql_instances: myproject:myzone:mydbinstance
env_variables:
    SQLALCHEMY_DATABASE_URI: >-
      postgresql+psycopg2://myuser:mypass@/mydb?host=/cloudsql/myproject:myzone:mydbinstance

Steps to reproduce:

  1. Create a GCP project A
  2. Create a Cloud SQL postgres instance in project A
  3. Deploy an app to app engine flexible environment in project A, following this steps to connect the app to Cloud SQL: https://cloud.google.com/appengine/docs/flexible/python/using-cloud-sql-postgres
  4. SSH into the instance in project A (via web console)
  5. $ ls /cloudsql/ -> should show the socket file
  6. Create a GCP project B
  7. Deploy the same app to app engine flexible environment in project B, following this steps to connect and authorize the app to project A's Cloud SQL: https://cloud.google.com/appengine/docs/flexible/python/using-cloud-sql-postgres
  8. SSH into the instance in project B (via web console)
  9. $ ls /cloudsql/ -> the directory is empty, the socket is not there.

How can I get project B to show the socket?

1

1 Answers

1
votes

I solved it by enabling the Cloud SQL Administration API for project B. Before, I only had it enabled for project A.