Execute cloud function from cloud data fusion - http

I'm trying to trigger the cloud function (with trigger type - HTTP) from cloud data fusion pipeline using http sink plugin version 1.2.2. However I receive the SSL error
java.io.EOFException: SSL peer shut down incorrectly
How do I fix this?
Any help is appreciated, Thanks

To my understanding, it is currently not possible to execute a Cloud Function from Cloud Data Fusion using the HTTP sink plugin. This is because you need an OIDC token which must be generated dynamically during runtime, as they have an expiration date. This is what is explained in this post. As explaind in the post, this token should then be added to the header of the request. To generate this token, you need to run a gcloud auth print-identity-token command, which you cant do using Data Fusion.
The only workaround I see is to Publish a Pub/Sub message at the end of the pipeline to trigger this Cloud Function (however, dont take this as the solution because I would need more context on the precise use-case).

Related

How To Use Event Arc Locally For Cloud Run?

So I am switching from cloud functions to Cloud Run and I am trying to figure out how to run Event Arc locally. I know you can set up an emulator for Eventarc using Firebase Emulator but Im not sure to have it trigger one of my Cloud Run functions when I write to my local Firestore db. Can someone please let me know how this can be done?
I did see one vague answer here:
Emulation of event-driven design in Cloud Run while developing locally?
But to me this doesn't make sense given that if Im using the local DB and local functions how would a remote instance work with my local dev environment. If this is possible please let me know and how I can accomplish this. Thanks.
It's not an easy task and the team is working to make the local tests easier. For now, I can share my hack.
First of all, you have to know that eventarc is roughtly a wrapper that create several resources behind the scene, especially a PubSub topic and Push subscription to your Cloud Run service. Because of that, an eventarc event is no more than a POST request with the event content as body.
For my hack, I have a Cloud Run service, on GCP, that log the headers and body of any incoming requests. I set up an eventarc with that service as target, and I trigger an event.
I go to the logs, copy the headers and the body of the received event, and I create a curl POST request with that.
Then, when I want to test my local service, I reuse my curl POST request, and submit it to my localhost server.

Authenticate Firebase app to invoke Google Cloud HTTP function

This is probably a dupe, but I have been searching for days now and I can't seem to figure it out.
Setup is fairly easy:
I have a firebase front-end (Dart) app (Web/Android) that gets it's data from a Google Cloud HTTP Function backend.
When I deploy the GC function with option --allow-unauthenticated obviously it works without any problems.
Now I want to secure this function so that only logged in users can actually invoke the GC function. What I don't want is to deal with the hassle of user-administration, but (as far is I understand) this can be dealt with by Firebase completely.
Can anybody in a step-by-step procedure explain to me what I have to do to accomplish this? (No links to docs please, I have kinda read them all...)
I have succeeded in retrieving a token from the Google Cloud Identity Toolkit, but when I use this token in the Authorization Header of an HTTP call, I get permission denied.
Also I have tried to create a Service Account and associate it with the GC function, but how do I get a Firebase token for this account? (If I need it at all)

Avoid spamming to my API that build with Firebase Function

I am building some internal API for my apps/website with Firebase Functions. Internal API as in to let my apps/website to process something on server side, its doesn't mean to open to public use.
My Apps is built with ionic and website is built with angular.
I noticed the one of Firebase Functions Pricing calculation include "Invocations". Is that Invocations means every time when I call the API equal to 1 Invocation? If yes, then the API might be abused by end user, since they able to view the website source and found the API.
I been searching solution in google, some of them suggest to enable authentication and cors, to avoid abuse of the usage. But authentication and cors still counting the Invocations right?
My code structure:
client call API by get/post method, pass user TOKEN that get from Firebase Authentication
request reach the Firebase Functions
server will check the preflight info by using CORS, as well as validate the TOKEN.
Return error if didn't pass on the (3), else proceed to execute the function.
So I assume if end user inspect my web source code and get the API URL, they can simply spam my API right? Then my bill will burst because of the load of Invocations.
If you suspect that your project is being abused, which is always possible, contact Firebase support to work towards a resolution.

BigQuery Automation using PUB/SUB trigger?

During bigquery automation i am deploying this https://github.com/firebase/functions-cron sample code. What changes i need to make in this. And not getting what is url, description. How to set url?
I have tried a BigQuery Automation using http trigger, hope it could be helpful. Here is what I did:
Create a Cloud Function that runs BigQuery query.
Keep the HTTP trigger url for step2. https://[your_project_ID].cloudfunctions.net/[your_cloud_funtion_name]
Create an App Engine App.
Since we cannot specify a Google Cloud Endpoint in the url field of a cron job, I created a handler to send the request to HTTP trigger url
Create cron.yaml that calls this handler every x minutes.
Deploy the application to App Engine.
$ gcloud app deploy app.yaml \cron.yaml
If you need more details, please post a comment and I will be happy to help.

Firebase: responding to http POST request

I was thinking of import my server Java code to firebase, basically replace my Dynamic web app with Jeresy and mongoDB to Firebase using hosting and functions .
I have implemented the sendWelcomeEmail and sendByeEmail with events user.created and user.deleted.
But now I want to do something more complicated.
Based on post request that comes from the mobile I want to extract the JSON data and then update the DataBase.
So I created js file with plenty of functions but now I am not sure it will actually work.
Is that the best way to implement this workflow.
The workflow goes like this.
Image is taken on the android device => extract information from image ==> upload the Json Data to the server (Firebase Hosting) => functions is been execute is response to POST request ==> extarct the data ==> save it to the Firebase Database.
Let me know if this sound ok, or I need to implent another workflow.
Thanks
Eran
The whole idea of Firebase is that your app talks directly to backend services (such as the database, or cloud storage), and you only write server-side code (with cloud functions) for functionality that Firebase doesn't provide a client-side API for.
Why don't you simply let the Android client write directly to the Firebase Database?

Resources