This document shows you how to use Cloud Functions to identify and clean up wasted cloud resources, schedule functions to run with Cloud Scheduler, and use Cloud Monitoring alerting policies to execute them based on observed usage. This document is intended for developers, SREs, cloud architects, and cloud infrastructure admins who are looking for a systematic and automated approach to identify and reduce wasteful cloud spending
https://cloud.google.com/architecture/automating-cost-optimizations-with-cloud-functions-cloud-scheduler-and-stackdriver