Automatically restart Compute Engine (GCE) instance when an alert gets trigerred

This post is for sharing the source code for an Youtube video posted on my channel.

In this video we are going to implement a system for automatically restarting a compute engine (GCE) instance when an alert gets triggered. Google Cloud doesn’t have this feature built in and I will discuss why I think this is. As a workaround we are going to write a Cloud Function with a Pub/Sub trigger and then the alert will publish on this Pub/Sub topic to start the process. We are going to write the Cloud Function in Python using the Compute Engine API via the Google API Python Client.

Leave a comment

Your email address will not be published. Required fields are marked *