firebase-functions
firebase-functions copied to clipboard
Unable to connect Cloud SQL with Firebase Functions V2
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
- Create a Firebase Functions that connects to a Cloud SQL database using a socket path like
/cloudsql/INSTANCE_CONNECTION_NAME
. - Call this function
- 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:
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.
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Unfortunately, because we clean up your docker image after deploy to save your money, you cannot edit the Run service without providing a new image. This feature should work and we'll look into it.
@inlined Thank you for the follow up! Glad to know it will be supported!
Any updates on this @inlined? I'm facing the same issue.
Have you found a workaround @service-paradis?
I think this feature request is duplicate of https://github.com/firebase/firebase-tools/issues/4932. Will use the other as it's in the more appropriate location. Feel free to re-open or to file another issue if I missed something.
I think this feature request is duplicate of firebase/firebase-tools#4932. Will use the other as it's in the more appropriate location. Feel free to re-open or to file another issue if I missed something.
@taeold I believe there's a difference between the two situations. When I attempted to manually update the service, I encountered an artifact error. However, ideally, we should be able to connect to a Cloud SQL database without the need to manually update services. Currently, Firebase functions version 1 can connect to Cloud SQL databases automatically. I would expect that version 2 could also connect with minimal effort required.
@taeold In fact, I'm not sure why the title have been changed since my issue is being unable to connect to Cloud SQL with Firebase Functions V2.