Skip to main content
Google Cloud Compute Engine is an Infrastructure-as-a-Service (IaaS) offering from GCP that allows you to run virtual machines (VMs), manage disks, networks, firewalls, snapshots, and images. This handler (GcpComputeHandler) provides methods to collect detailed information about Compute resources for governance, auditing, and monitoring purposes. It authenticates using a GCP service account and leverages the Google Cloud SDK (google-cloud-compute) to fetch data.

Example

To create the GcpComputeHandler object with your service account:
Collect Instances:
Retrieve details of all VM instances in a project or specific zone.
Collect Disks:
Fetch persistent disk information across all zones or a specific zone.
Collect Networks:
Get all VPC networks within a project.
Collect Subnetworks:
Retrieve subnetworks across all regions or a specific region.
Collect Firewall Rules:
Fetch firewall rules that define ingress/egress traffic control for resources.
Collect Images:
Retrieve custom images created in the project.
Collect Snapshots:
Fetch disk snapshots for backup and disaster recovery.
Collect All Compute Info:
Retrieve a comprehensive dictionary with all compute resources (instances, disks, networks, subnetworks, firewalls, images, and snapshots).