steampipe plugin install gcp

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_count
from
gcp_compute_snapshot
group by
source_disk_name;
select
source_disk_name,
count(*) as snapshot_count
from
gcp_compute_snapshot
group 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_created
from
gcp_compute_snapshot
where
not auto_created;
select
name,
source_disk_name,
auto_created
from
gcp_compute_snapshot
where
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_type
from
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_type
from
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_snapshot
where
creation_timestamp <= (current_date - interval '90' day)
order by
creation_timestamp;
select
name,
creation_timestamp,
julianday('now') - julianday(creation_timestamp) as age
from
gcp_compute_snapshot
where
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_link
from
gcp_compute_snapshot
where
kms_key_name is null;
select
name,
source_disk,
self_link
from
gcp_compute_snapshot
where
kms_key_name is null;

Schema for gcp_compute_snapshot

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
akasjsonbArray of globally unique identifier strings (also known as) for the resource.
auto_createdboolean!=, =Set to true if snapshots are automatically created by applying resource policy on the target disk.
creation_timestamptimestamp with time zoneTimestamp when snapshot was created.
descriptiontextAn optional description of this resource.
disk_size_gbbigintSize of the source disk, specified in GB.
download_bytesbigintNumber of bytes downloaded to restore a snapshot to a disk.
encryption_key_raw_keytextSpecifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource.
encryption_key_sha256textThe RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.
kms_key_nametextThe name of the encryption key that is used to encrypt snapshot
kms_key_service_accounttextThe service account being used for the encryption request for the given KMS key. If absent, the Compute Engine default service account is used.
label_fingerprinttextA 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.
labelsjsonbLabels applied to this snapshot.
licensesjsonbA 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).
locationtextThe GCP multi-region, region, or zone in which the resource is located.
nametext=Name of the resource; provided by the client when the resource is created.
projecttextThe GCP Project in which the resource is located.
self_linktextServer-defined URL for the resource.
source_disktextThe url of the source disk used to create this snapshot.
source_disk_encryption_keyjsonbThe customer-supplied encryption key of the source disk.
source_disk_nametextThe name of the source disk used to create this snapshot.
statustext!=, =The status of the snapshot. This can be CREATING, DELETING, FAILED, READY, or UPLOADING.
storage_bytesbigintA size of the storage used by the snapshot. As snapshots share storage, this number is expected to change with snapshot creation/deletion.
storage_bytes_statustext!=, =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_locationsjsonbCloud Storage bucket storage location of the snapshot (regional or multi-regional).
tagsjsonbA map of tags for the resource.
titletextTitle 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