turbot/alicloud
steampipe plugin install alicloud

Table: alicloud_ecs_snapshot - Query Alibaba Cloud ECS Snapshots using SQL

Elastic Compute Service (ECS) Snapshots in Alibaba Cloud are a point-in-time copy of ECS disk data. Snapshots are used for data backup and restoration, disaster recovery, and migration across regions and zones. They provide a cost-effective and efficient way to create copies of data at a specific point in time.

Table Usage Guide

The alicloud_ecs_snapshot table provides insights into ECS Snapshots within Alibaba Cloud Elastic Compute Service (ECS). As a DevOps engineer, explore snapshot-specific details through this table, including snapshot status, creation time, and associated metadata. Utilize it to uncover information about snapshots, such as those that are unused, the relationships between snapshots and disks, and the verification of snapshot policies.

Examples

List of snapshots which are not encrypted

Determine the areas in which snapshots lack encryption, allowing you to enhance your system's security by identifying potential vulnerabilities.

select
name,
snapshot_id,
arn,
encrypted
from
alicloud_ecs_snapshot
where
not encrypted;
select
name,
snapshot_id,
arn,
encrypted
from
alicloud_ecs_snapshot
where
encrypted = 0;

List of unused snapshots

Discover the snapshots which are currently not in use within your Alicloud Elastic Compute Service. This can help in managing resources efficiently by identifying and removing unused elements.

select
name,
snapshot_id,
type
from
alicloud_ecs_snapshot
where
usage = 'none';
select
name,
snapshot_id,
type
from
alicloud_ecs_snapshot
where
usage = 'none';

Find the snapshot count per disk

Uncover the details of how many snapshots each disk holds in your Alicloud ECS environment. This is useful in understanding the frequency of snapshots taken and can aid in storage management and cost optimization.

select
source_disk_id,
count(*) as snapshot
from
alicloud_ecs_snapshot
group by
source_disk_id;
select
source_disk_id,
count(*) as snapshot
from
alicloud_ecs_snapshot
group by
source_disk_id;

List of snapshots without owner tag key

Discover the segments that consist of snapshots lacking an 'owner' tag. This is particularly useful for identifying untagged resources that may lead to management issues or unnecessary costs.

select
name,
snapshot_id,
tags
from
alicloud_ecs_snapshot
where
tags ->> 'owner' is null;
select
name,
snapshot_id,
tags
from
alicloud_ecs_snapshot
where
json_extract(tags, '$.owner') is null;

List of snapshots older than 90 days

Determine the areas in which snapshots are older than 90 days in order to identify potential areas for data cleanup or archival. This can help optimize storage use and manage costs effectively.

select
name,
snapshot_id,
type,
creation_time,
age(creation_time),
retention_days
from
alicloud_ecs_snapshot
where
creation_time <= (current_date - interval '90' day)
order by
creation_time;
select
name,
snapshot_id,
type,
creation_time,
julianday('now') - julianday(creation_time) as age,
retention_days
from
alicloud_ecs_snapshot
where
julianday(creation_time) <= julianday(date('now', '-90 day'))
order by
creation_time;

Schema for alicloud_ecs_snapshot

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
account_idtext=, !=, ~~, ~~*, !~~, !~~*The alicloud Account ID in which the resource is located.
akasjsonbArray of globally unique identifier strings (also known as) for the resource.
arntextThe Alibaba Cloud Resource Name (ARN) of the snapshot.
creation_timetimestamp with time zoneThe time when the snapshot was created.
descriptiontextA user provided, human readable description for this resource.
encryptedbooleanIndicates whether the snapshot was encrypted.
instant_accessbooleanIndicates whether the instant access feature is enabled.
instant_access_retention_daysbigintIndicates the retention period of the instant access feature. After the retention per iod ends, the snapshot is automatically released.
kms_key_idtextThe ID of the KMS key used by the data disk.
last_modified_timetimestamp with time zoneThe time when the snapshot was last changed.
nametext=A friendly name for the resource.
product_codetextThe product code of the Alibaba Cloud Marketplace image.
progresstextThe progress of the snapshot creation task. Unit: percent (%).
regiontextThe region ID where the resource is located.
remain_timebigintThe remaining time required to create the snapshot (in seconds).
resource_group_idtextThe ID of the resource group to which the snapshot belongs.
retention_daysbigintThe number of days that an automatic snapshot can be retained.
serial_numbertextThe serial number of the snapshot.
snapshot_idtextAn unique identifier for the resource.
source_disk_idtextThe ID of the source disk. This parameter is retained even after the source disk of the snapshot is released.
source_disk_sizetextThe capacity of the source disk (in GiB).
source_disk_typetextThe category of the source disk.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
statustextSpecifies the current state of the resource.
tagsjsonbA map of tags for the resource.
tags_srcjsonbA list of tags attached with the resource.
titletextTitle of the resource.
typetextThe type of the snapshot. Default value: all. Possible values are: auto, user, and all.
usagetextIndicates whether the snapshot has been used to create images or disks.

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)" -- alicloud

You can pass the configuration to the command with the --config argument:

steampipe_export_alicloud --config '<your_config>' alicloud_ecs_snapshot