turbot/alicloud
steampipe plugin install alicloud

Table: alicloud_ecs_image - Query Alibaba Cloud Elastic Compute Service Images using SQL

Alibaba Cloud Elastic Compute Service (ECS) provides fast memory and the latest Intel CPUs to help you to power your cloud applications and achieve faster results with low latency. All ECS instances come with Anti-DDoS protection to safeguard your data and applications from DDoS and Trojan attacks. ECS offers a variety of instance types optimized to fit different use cases and provides the flexibility to choose the appropriate mix of resources for your applications.

Table Usage Guide

The alicloud_ecs_image table provides insights into the Elastic Compute Service Images within Alibaba Cloud. As a Cloud Engineer, explore image-specific details through this table, including image configurations, usage, and associated metadata. Utilize it to uncover information about images, such as those with specific configurations, the relationships between images and instances, and the verification of image usage.

Examples

Image basic info

Explore the basic details of your images in the Alibaba Cloud ECS service. This query helps you manage your resources by providing insights into image names, sizes, statuses, and usage patterns.

select
name,
image_id,
arn,
size,
status,
usage
from
alicloud_ecs_image;
select
name,
image_id,
arn,
size,
status,
usage
from
alicloud_ecs_image;

List of public images

Discover the segments that are using system-owned images in your environment. This is useful for understanding what resources are publicly available and potentially vulnerable.

select
name,
image_id,
image_owner_alias
from
alicloud_ecs_image
where
image_owner_alias = 'system';
select
name,
image_id,
image_owner_alias
from
alicloud_ecs_image
where
image_owner_alias = 'system';

List of custom (user-defined) images defined in this account

Explore the custom images created within your account to gain insights into their details such as size, status, architecture, and operating system. This can be beneficial in managing resources and ensuring optimal usage.

select
name,
image_id,
image_owner_alias,
is_self_shared,
size,
status,
architecture,
os_name_en
from
alicloud_ecs_image
where
image_owner_alias = 'self';
select
name,
image_id,
image_owner_alias,
is_self_shared,
size,
status,
architecture,
os_name_en
from
alicloud_ecs_image
where
image_owner_alias = 'self';

List of user-defined images which do not have owner tag key

Discover the user-defined images that lack an owner tag key. This can be useful in managing and organizing your images, ensuring that each has an owner associated with it for accountability and easy tracking.

select
name,
image_id,
tags
from
alicloud_ecs_image
where
tags -> 'owner' is null
and image_owner_alias = 'self';
select
name,
image_id,
tags
from
alicloud_ecs_image
where
json_extract(tags, '$.owner') is null
and image_owner_alias = 'self';

List of available images older than 90 days

Discover the segments that contain images available for over 90 days. This query is beneficial in managing resources by identifying older, potentially unused images that may be taking up unnecessary storage space.

select
name,
image_id,
creation_time,
age(creation_time),
status
from
alicloud_ecs_image
where
creation_time <= (current_date - interval '90' day)
and status = 'Available'
order by
creation_time;
select
name,
image_id,
creation_time,
julianday('now') - julianday(creation_time) as age,
status
from
alicloud_ecs_image
where
julianday(creation_time) <= julianday(date('now', '-90 day'))
and status = 'Available'
order by
creation_time;

List of unused images

Discover the segments that contain unused images in your Alicloud ECS, allowing you to manage your resources more efficiently by identifying and removing unnecessary data.

select
name,
image_id
from
alicloud_ecs_image
where
usage = 'none';
select
name,
image_id
from
alicloud_ecs_image
where
usage = 'none';

List of instances created from an image older than 90 days old

Identify instances that were created from an image that's over 90 days old. This can be useful for maintaining up-to-date system images and ensuring that instances are not running on outdated software.

select
instance.name as instance_name,
instance.instance_id as instance_id,
image.name as image_name,
instance.status as instance_status,
age(image.creation_time) as image_age,
age(instance.creation_time) as instance_age
from
alicloud_ecs_image as image,
alicloud_ecs_instance as instance
where
instance.image_id = image.image_id
and image.creation_time <= (current_date - interval '90' day)
select
instance.name as instance_name,
instance.instance_id as instance_id,
image.name as image_name,
instance.status as instance_status,
julianday('now') - julianday(image.creation_time) as image_age,
julianday('now') - julianday(instance.creation_time) as instance_age
from
alicloud_ecs_image as image,
alicloud_ecs_instance as instance
where
instance.image_id = image.image_id
and date(image.creation_time) <= date(julianday('now', '-90 day'))

Get details of a particular image

Determine the specifics of a particular image, such as its size and status, within a specified region. This is useful for assessing the usage and availability of an image in a specific geographical location.

select
name,
image_id,
arn,
size,
status,
usage
from
alicloud_ecs_image
where
image_id = 'centos_7_9_x64_20G_alibase_20221129.vhd'
and region = 'us-east-1';
select
name,
image_id,
arn,
size,
status,
usage
from
alicloud_ecs_image
where
image_id = 'centos_7_9_x64_20G_alibase_20221129.vhd'
and region = 'us-east-1';

Schema for alicloud_ecs_image

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.
architecturetextThe image architecture. Possible values are: 'i386', and 'x86_64'.
arntextThe Alibaba Cloud Resource Name (ARN) of the ECS image.
creation_timetimestamp with time zoneThe time when the image was created.
descriptiontextA user-defined, human readable description for the image.
disk_device_mappingsjsonbThe mappings between disks and snapshots under the image.
image_familytextThe name of the image family.
image_idtext=The ID of the image that the instance is running.
image_owner_aliastextThe alias of the image owner. Possible values are: system, self, others, marketplace.
image_versiontextThe version of the image.
is_copiedbooleanIndicates whether the image is a copy of another image.
is_self_sharedbooleanIndicates whether the image has been shared to other Alibaba Cloud accounts.
is_subscribedbooleanIndicates whether you have subscribed to the image that corresponds to the specified product code.
is_support_cloud_initbooleanIndicates whether the image supports cloud-init.
is_support_io_optimizedbooleanIndicates whether the image can be used on I/O optimized instances.
nametextA friendly name of the resource.
os_nametextThe Chinese name of the operating system.
os_name_entextThe English name of the operating system.
os_typetextThe type of the operating system. Possible values are: windows,and linux
platformtextThe platform of the operating system.
product_codetextThe product code of the Alibaba Cloud Marketplace image.
progresstextThe image creation progress, in percent(%).
regiontext=The Alicloud region in which the resource is located.
resource_group_idtextThe ID of the resource group to which the image belongs.
share_permissionsjsonbA list of groups and accounts that the image can be shared.
sizebigintThe size of the image (in GiB).
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
statustextThe status of the image.
tagsjsonbA map of tags for the resource.
tags_srcjsonbA list of tags attached with the image.
titletextTitle of the resource.
usagetextIndicates whether the image has been used to create ECS instances.

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_image