/sql-to-sheet

This Google Cloud Function appends SQL results to a Google Sheet

Primary LanguagePythonMIT LicenseMIT

sql-to-sheet

This Google Cloud Function appends SQL results to a Google Sheet

GCP Diagram

Set Up Your VPC Network

  1. Create a VPC network and configure its firewall rules according to your needs
  2. Configure serverless VPC access and create a connector

Create and Configure Your Cloud Function

  1. Create an HTTP Cloud Function
  2. Configure the function's ingress settings to allow all traffic or internal traffic only if you want a private function
  3. Configure the function's egress settings to route all traffic through the connector
  4. Deploy your function

At this point all traffic originating from your function will follow your VPC firewall rules. But wait, now your function is unable to access the public internet until you configure Cloud NAT.

Set Up Your Cloud Router and NAT

  1. Setup Cloud NAT and specify a static ip address

Congratulations! Now your function's egress traffic originates from your static ip address.

Store Your Secrets Securely

  1. Create and access secrets such as a database connection string or the private key of a service account
  2. Store the resource ids of your secrets as environment variables so you can access them at run time

Create and Configure Your Cron Jobs with Cloud Scheduler

  1. Define a schedule using a unix-cron configuration string
  2. Specify the target as the HTTP endpoint of your Cloud Function

Pricing