This Google Cloud Function appends SQL results to a Google Sheet
- Create a VPC network and configure its firewall rules according to your needs
- Configure serverless VPC access and create a connector
- Create an HTTP Cloud Function
- Configure the function's ingress settings to allow all traffic or internal traffic only if you want a private function
- Configure the function's egress settings to route all traffic through the connector
- 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.
Congratulations! Now your function's egress traffic originates from your static ip address.
- Create and access secrets such as a database connection string or the private key of a service account
- Store the resource ids of your secrets as environment variables so you can access them at run time
- Define a schedule using a unix-cron configuration string
- Specify the target as the HTTP endpoint of your Cloud Function
- Cloud Functions, Serverless VPC Access, Cloud NAT, Secret Manager and Cloud Scheduler are paid products that require biling to use.
- The first 2 million Cloud Function invocations per month are free Phew
- Serverless VPC Access and Cloud NAT charges are based on the ammount of traffic that is processed.
- Serverless VPC Access Pricing
- Cloud NAT Pricing
- Secret Manager charges are based on how many secrets you keep and how many times per month they are accessed
- Cloud Scheduler offers 3 jobs per month free and charges $0.10 per job per month after that