Skip to content

Unable to connect Cloud SQL with Firebase Functions V2 #1217

Closed
@service-paradis

Description

@service-paradis

Related issues

[REQUIRED] Version info

node: 16.16.0

firebase-functions: 3.22.0

firebase-tools: 11.4.0

firebase-admin: 11.0.1

[REQUIRED] Test case

I'm trying to migrate a Firebase Functions from V1 to V2 to try beta features. It looked like Cloud SQL connection are not yet supported, but did not find anything in the documentation about it.

[REQUIRED] Steps to reproduce

  1. Create a Firebase Functions that connects to a Cloud SQL database using a socket path like /cloudsql/INSTANCE_CONNECTION_NAME.
  2. Call this function
  3. Get an ENOENT error that were not received using V1

[REQUIRED] Expected behavior

I expected that Cloud SQL would be available to the function.

[REQUIRED] Actual behavior

I got ENOENT error while trying to connect to the database. According to https://cloud.google.com/sql/docs/mysql/connect-run?hl=fr#console, it looks like I would need to add a Cloud SQL connection to my service. I'm not sure how to this while deploying my function using Firebase Tools.

I tried adding the Cloud SQL connection using the console, but it fails with this error:
image

I tried using the cli with something like gcloud run services update api --add-cloudsql-instances=INSTANCE_CONNECTION_NAME, but it gives me the sdame kind of errors like:

Deployment failed
ERROR: (gcloud.run.services.update) Image 'us-central1-docker.pkg.dev/PROJECT_NAME/gcf-artifacts/api:version_1' not found.

Were you able to successfully deploy your functions?

Yes, without any errors. The function itself seems to be working as expected, but it cannot connect to a Cloud SQL instance.

If this is possible, the information is missing in the doc.

If this is not yet possible using the beta functions, the information is also missing from the doc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions