Table: gcp_compute_snapshot - Query Compute Engine Snapshots using SQL
A Compute Engine Snapshot in Google Cloud Platform (GCP) is a copy of a virtual machine's disk at a specific point in time. Snapshots are used for backing up data, duplicating disks, and creating images for boot disks. They capture the entire state of a disk, including all data, installed applications, and system settings.
Table Usage Guide
The gcp_compute_snapshot
table provides insights into Compute Engine Snapshots within Google Cloud Platform (GCP). As a system administrator, explore snapshot-specific details through this table, including snapshot status, storage locations, and associated metadata. Utilize it to uncover information about snapshots, such as their creation time, disk size, and the source disk's ID.
Examples
Count of snapshots per disk
Analyze the distribution of snapshots across various disks to understand the backup frequency for each disk. This can be useful for ensuring regular backups are being made for all important data.
select source_disk_name, count(*) as snapshot_countfrom gcp_compute_snapshotgroup by source_disk_name;
select source_disk_name, count(*) as snapshot_countfrom gcp_compute_snapshotgroup by source_disk_name;
List of manually created snapshots
Explore which disk snapshots in your Google Cloud Platform (GCP) Compute Engine have been manually created. This can help you manage and differentiate them from automatically generated snapshots.
select name, source_disk_name, auto_createdfrom gcp_compute_snapshotwhere not auto_created;
select name, source_disk_name, auto_createdfrom gcp_compute_snapshotwhere auto_created = 0;
Disk info for each snapshot
Explore the details of each snapshot in your Google Cloud Platform's compute engine, including the associated disk's name, size, type, and location. This is particularly useful for managing resources and understanding the composition of your snapshots.
select s.name as snapshot_name, d.name as disk_name, d.size_gb as disk_size, d.type_name as disk_type, d.location_typefrom gcp_compute_snapshot as s join gcp_compute_disk as d on s.source_disk = d.self_link;
select s.name as snapshot_name, d.name as disk_name, d.size_gb as disk_size, d.type_name as disk_type, d.location_typefrom gcp_compute_snapshot as s join gcp_compute_disk as d on s.source_disk = d.self_link;
List of snapshots older than 90 days
Determine the areas in which system snapshots have been stored for over 90 days. This can be helpful for managing storage resources and identifying potential data that could be archived or deleted.
select name, creation_timestamp, age(creation_timestamp)from gcp_compute_snapshotwhere creation_timestamp <= (current_date - interval '90' day)order by creation_timestamp;
select name, creation_timestamp, julianday('now') - julianday(creation_timestamp) as agefrom gcp_compute_snapshotwhere julianday(creation_timestamp) <= julianday('now', '-90 day')order by creation_timestamp;
List of snapshots with Google-managed key
Explore which snapshots are using Google-managed keys. This is useful to ensure your data is properly encrypted and secure.
select name, source_disk, self_linkfrom gcp_compute_snapshotwhere kms_key_name is null;
select name, source_disk, self_linkfrom gcp_compute_snapshotwhere kms_key_name is null;
Query examples
Schema for gcp_compute_snapshot
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
auto_created | boolean | !=, = | Set to true if snapshots are automatically created by applying resource policy on the target disk. |
creation_timestamp | timestamp with time zone | Timestamp when snapshot was created. | |
description | text | An optional description of this resource. | |
disk_size_gb | bigint | Size of the source disk, specified in GB. | |
download_bytes | bigint | Number of bytes downloaded to restore a snapshot to a disk. | |
encryption_key_raw_key | text | Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource. | |
encryption_key_sha256 | text | The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource. | |
kms_key_name | text | The name of the encryption key that is used to encrypt snapshot | |
kms_key_service_account | text | The service account being used for the encryption request for the given KMS key. If absent, the Compute Engine default service account is used. | |
label_fingerprint | text | A fingerprint for the labels being applied to this snapshot, which is essentially a hash of the labels set used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. | |
labels | jsonb | Labels applied to this snapshot. | |
licenses | jsonb | A list of public visible licenses that apply to this snapshot. This can be because the original image had licenses attached (such as a Windows image). | |
location | text | The GCP multi-region, region, or zone in which the resource is located. | |
name | text | = | Name of the resource; provided by the client when the resource is created. |
project | text | =, !=, ~~, ~~*, !~~, !~~* | The GCP Project in which the resource is located. |
self_link | text | Server-defined URL for the resource. | |
source_disk | text | The url of the source disk used to create this snapshot. | |
source_disk_encryption_key | jsonb | The customer-supplied encryption key of the source disk. | |
source_disk_name | text | The name of the source disk used to create this snapshot. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
status | text | !=, = | The status of the snapshot. This can be CREATING, DELETING, FAILED, READY, or UPLOADING. |
storage_bytes | bigint | A size of the storage used by the snapshot. As snapshots share storage, this number is expected to change with snapshot creation/deletion. | |
storage_bytes_status | text | !=, = | An indicator whether storageBytes is in a stable state or it is being adjusted as a result of shared storage reallocation. This status can either be UPDATING, meaning the size of the snapshot is being updated, or UP_TO_DATE, meaning the size of the snapshot is up-to-date. |
storage_locations | jsonb | Cloud Storage bucket storage location of the snapshot (regional or multi-regional). | |
tags | jsonb | A map of tags for the resource. | |
title | text | Title of the resource. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- gcp
You can pass the configuration to the command with the --config
argument:
steampipe_export_gcp --config '<your_config>' gcp_compute_snapshot