Accessing Cloud SQL from Cloud Run on Google Cloud

pete

I have a Cloud Run service that accesses a Cloud SQL instance through SQLAlchemy. However, in the logs for Cloud Run, I see CloudSQL connection failed. Please see https://cloud.google.com/sql/docs/mysql/connect-run for additional details: ensure that the account has access to "<connection_string>". Going to that link, it says that:

"By default, your app will authorize your connections using the Cloud Run (fully managed) service account. The service account is in the format [email protected]."

However, the following (https://cloud.google.com/run/docs/securing/service-identity) says:

"By default, Cloud Run revisions are using the Compute Engine default service account ([email protected]), which has the Project > Editor IAM role. This means that by default, your Cloud Run revisions have read and write access to all resources in your Google Cloud project."

So shouldn't that mean that Cloud Run can already access SQL? I've already set up the Cloud SQL Connection in the Cloud Run deployment page. What do you suggest I do to allow access to Cloud SQL from Cloud Run?

EDIT: I have to enable the Cloud SQL API.

AhmetB - Google

No, Cloud Run cannot access to Cloud SQL by default. You need to follow one of the two paths.

  1. Connect to SQL using a local unix socket file: You need to configure permissions like you said and deploy with flags indicating intent to connect to the database. Follow https://cloud.google.com/sql/docs/mysql/connect-run

  2. Connect to SQL with a private IP: This involves deploying Cloud SQL instance into a VPC Network and therefore having it get a private IP address. Then you use Cloud Run VPC Access Connector (currently beta) to allow Cloud Run container to be able to connect to that VPC network, which includes SQL database's IP address directly (no IAM permissions needed). Follow https://cloud.google.com/vpc/docs/configure-serverless-vpc-access

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

EF Core connect from Google Cloud Run to Google Cloud SQL

From Dev

Google cloud run cannot reach Cloud SQL

From Dev

Google Cloud Run API - accessing endpoint internally

From Dev

Accessing and using csv file from Cloud Storage in Cloud Run instance

From Dev

Connect To Google Cloud Sql From Metabase cloud

From Dev

Accessing GCP Memorystore from Google Cloud Platform Cloud Shell

From Dev

Accessing Firebase admin from google cloud functions

From Dev

Accessing files from Google cloud storage in RStudio

From Dev

Accessing Google cloud platform from China

From Dev

Accessing Cloud SQL from another GCP project

From Dev

Use hasura with Google Cloud Run and Google Cloud SQL

From Dev

Connecting Google Cloud Run Service to Google Cloud SQL database

From Dev

Connecting to a Google Cloud SQL instance from a Google Cloud Run docker image

From Dev

How to use cloud build to deploy cloud run with cloud sql on google cloud?

From Dev

Accessing a Postgres SQL Server from a Google cloud (gcp) account using another Google cloud (gcp) account which has a virtual machine

From Dev

How can you connect to Google Cloud Datastore from Cloud Run?

From Dev

Import CSV file from Google Cloud Storage to Google Cloud SQL

From Dev

How to securely connect to Cloud SQL from Cloud Run?

From Dev

Google Cloud Run: Calling from outside GCP

From Java

Invoke a Google Cloud Run from java

From Dev

Run chrome extension from Google Cloud Shell

From Javascript

How to connect Google Cloud SQL from Cloud Functions?

From Dev

Connecting to Cloud SQL from Google Cloud Function using Python and SQLAlchemy

From Dev

Google Cloud Tasks cannot authenticate to Cloud Run

From Dev

Accessing files in the Google Cloud Storage from two different google cloud projects

From Dev

Accessing Google Secrets from an application running on a Google Cloud VM instance - Assigning Cloud APIs to VM

From Dev

Accessing request parameters from Google Cloud Endpoints that have not been named

From Dev

Exception accessing Google Cloud Storage from newly created Compute Engine

From Dev

Accessing images from google cloud bucket (smiliar to folder)

Related Related

  1. 1

    EF Core connect from Google Cloud Run to Google Cloud SQL

  2. 2

    Google cloud run cannot reach Cloud SQL

  3. 3

    Google Cloud Run API - accessing endpoint internally

  4. 4

    Accessing and using csv file from Cloud Storage in Cloud Run instance

  5. 5

    Connect To Google Cloud Sql From Metabase cloud

  6. 6

    Accessing GCP Memorystore from Google Cloud Platform Cloud Shell

  7. 7

    Accessing Firebase admin from google cloud functions

  8. 8

    Accessing files from Google cloud storage in RStudio

  9. 9

    Accessing Google cloud platform from China

  10. 10

    Accessing Cloud SQL from another GCP project

  11. 11

    Use hasura with Google Cloud Run and Google Cloud SQL

  12. 12

    Connecting Google Cloud Run Service to Google Cloud SQL database

  13. 13

    Connecting to a Google Cloud SQL instance from a Google Cloud Run docker image

  14. 14

    How to use cloud build to deploy cloud run with cloud sql on google cloud?

  15. 15

    Accessing a Postgres SQL Server from a Google cloud (gcp) account using another Google cloud (gcp) account which has a virtual machine

  16. 16

    How can you connect to Google Cloud Datastore from Cloud Run?

  17. 17

    Import CSV file from Google Cloud Storage to Google Cloud SQL

  18. 18

    How to securely connect to Cloud SQL from Cloud Run?

  19. 19

    Google Cloud Run: Calling from outside GCP

  20. 20

    Invoke a Google Cloud Run from java

  21. 21

    Run chrome extension from Google Cloud Shell

  22. 22

    How to connect Google Cloud SQL from Cloud Functions?

  23. 23

    Connecting to Cloud SQL from Google Cloud Function using Python and SQLAlchemy

  24. 24

    Google Cloud Tasks cannot authenticate to Cloud Run

  25. 25

    Accessing files in the Google Cloud Storage from two different google cloud projects

  26. 26

    Accessing Google Secrets from an application running on a Google Cloud VM instance - Assigning Cloud APIs to VM

  27. 27

    Accessing request parameters from Google Cloud Endpoints that have not been named

  28. 28

    Exception accessing Google Cloud Storage from newly created Compute Engine

  29. 29

    Accessing images from google cloud bucket (smiliar to folder)

HotTag

Archive