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, usagefrom alicloud_ecs_image;
select name, image_id, arn, size, status, usagefrom 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_aliasfrom alicloud_ecs_imagewhere image_owner_alias = 'system';
select name, image_id, image_owner_aliasfrom alicloud_ecs_imagewhere 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_enfrom alicloud_ecs_imagewhere image_owner_alias = 'self';
select name, image_id, image_owner_alias, is_self_shared, size, status, architecture, os_name_enfrom alicloud_ecs_imagewhere 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, tagsfrom alicloud_ecs_imagewhere tags -> 'owner' is null and image_owner_alias = 'self';
select name, image_id, tagsfrom alicloud_ecs_imagewhere 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), statusfrom alicloud_ecs_imagewhere 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, statusfrom alicloud_ecs_imagewhere 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_idfrom alicloud_ecs_imagewhere usage = 'none';
select name, image_idfrom alicloud_ecs_imagewhere 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_agefrom alicloud_ecs_image as image, alicloud_ecs_instance as instancewhere 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_agefrom alicloud_ecs_image as image, alicloud_ecs_instance as instancewhere 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, usagefrom alicloud_ecs_imagewhere image_id = 'centos_7_9_x64_20G_alibase_20221129.vhd' and region = 'us-east-1';
select name, image_id, arn, size, status, usagefrom alicloud_ecs_imagewhere image_id = 'centos_7_9_x64_20G_alibase_20221129.vhd' and region = 'us-east-1';
Schema for alicloud_ecs_image
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The Alicloud Account ID in which the resource is located. |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
architecture | text | The image architecture. Possible values are: 'i386', and 'x86_64'. | |
arn | text | The Alibaba Cloud Resource Name (ARN) of the ECS image. | |
creation_time | timestamp with time zone | The time when the image was created. | |
description | text | A user-defined, human readable description for the image. | |
disk_device_mappings | jsonb | The mappings between disks and snapshots under the image. | |
image_family | text | The name of the image family. | |
image_id | text | = | The ID of the image that the instance is running. |
image_owner_alias | text | The alias of the image owner. Possible values are: system, self, others, marketplace. | |
image_version | text | The version of the image. | |
is_copied | boolean | Indicates whether the image is a copy of another image. | |
is_self_shared | boolean | Indicates whether the image has been shared to other Alibaba Cloud accounts. | |
is_subscribed | boolean | Indicates whether you have subscribed to the image that corresponds to the specified product code. | |
is_support_cloud_init | boolean | Indicates whether the image supports cloud-init. | |
is_support_io_optimized | boolean | Indicates whether the image can be used on I/O optimized instances. | |
name | text | A friendly name of the resource. | |
os_name | text | The Chinese name of the operating system. | |
os_name_en | text | The English name of the operating system. | |
os_type | text | The type of the operating system. Possible values are: windows,and linux | |
platform | text | The platform of the operating system. | |
product_code | text | The product code of the Alibaba Cloud Marketplace image. | |
progress | text | The image creation progress, in percent(%). | |
region | text | = | The Alicloud region in which the resource is located. |
resource_group_id | text | The ID of the resource group to which the image belongs. | |
share_permissions | jsonb | A list of groups and accounts that the image can be shared. | |
size | bigint | The size of the image (in GiB). | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
status | text | The status of the image. | |
tags | jsonb | A map of tags for the resource. | |
tags_src | jsonb | A list of tags attached with the image. | |
title | text | Title of the resource. | |
usage | text | Indicates 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