Steps to connect GCP Cloud functions to Fly Postgres

Hello
I have a terraform scripts pub/sub that do a lot of of data processing on schedule, using gcp. In those scripts I connect to postgres database on fly.

Recently I lost the dev database and re-created it from scratch.
I wanted to securely connect gcp pubsub/cloud function to postgres on fly.io.

Where can I find the steps to do that? or if one can comment what they are. List of commands that do the job would be great and very much appreciated!

Thanks
Lucas

In general, designing systems architecture is about taking a problem and breaking the problem down. I would split it into these pieces:

  • Exposing a Postgres port inside Fly that can be connected to from GCP
  • Deciding what encryption/transport you need between the two cloud systems e.g. Wireguard
  • Doing some technical experimentation to see what the latency is like for the regions you’d like to use
  • Choosing an implementation language for your GCP function
  • Writing the code and importing drivers etc
  • Capturing your choices and discoveries in IaC

Each of these pieces then become work from first principles, and can either be looked up in the manual, or discovered with technical experimentation. In other words, the steps to do what you want are not written down in a single step-by-step guide, and most of the trick is piecing together many documentation items to achieve your overall goal.

Thank you @halfer

Since My GCP process is already written and working, latency doesn’t matter since this is end of day processing, (at least for now).
The only step I need is to connect to internal instance’s port.

I was hoping for:(not actual commands, wants)
fly wireguard abcd
gcp create proxy abcd -appname
gcp forward appname:1234 to fly abcd:1234 --use wireguard abcd.conf

update config in my terraform to point to appname:1234

vs
become expert in wireguard and all its configurations, allowed encryption, pci4.0 dss rules, expert in fly, expert in gcp and all its configuration, run yet another instance in gcp.

Simplicity and specificity to accomplish task and be live within 48h.

I just did a Duck-powered :duck: search for “fly io expose database to cloud” and found this:

Any good?

I hear you about simplicity, but the correct answer is generally “it depends”. I would strongly doubt someone here can list commands that could be typed in verbatim. Thus, an hour or two experimenting with your GCP and Fly consoles would be time well spent.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.