Skip to content

Instantly share code, notes, and snippets.

@jdecode
Created January 20, 2022 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdecode/f2c4471467259015b812219bc67abc6a to your computer and use it in GitHub Desktop.
Save jdecode/f2c4471467259015b812219bc67abc6a to your computer and use it in GitHub Desktop.
Setup Cloud SQL with Cloud Run

Note : This is for Laravel/PHP setup only (should work with other stacks, but not tested)

  1. Setup a Cloud SQL instance
  2. Setup a Cloud Run service
  3. Connect the Cloud SQL instance to Cloud Run service under "connections"
  4. Add environment variables (directly or via secret manager) as per the specifications mentioned here: https://cloud.google.com/sql/docs/postgres/connect-run?authuser=1#connecting_to
  5. For Laravel, the DB_HOST ENV VAR should be of the format : /cloudsql/project-id:region-id:db-instane-name
  6. Additionally, add "Cloud SQL Client" role to the default compute account (Under IAM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment