turbot/alicloud
steampipe plugin install alicloud

Table: alicloud_ecs_instance

An ECS instance is a virtual machine that contains basic computing components such as the vCPU, memory, operating system, network, and disk.

Examples

Basic Instance Info

Assess the elements within your Alibaba Cloud ECS instances to gain insights into their operational status, type, and network details. This can help in managing resources, ensuring optimal performance, and identifying potential issues.

select
instance_id,
name,
arn,
status,
instance_type,
os_name_en,
public_ip_address,
private_ip_address,
zone
from
alicloud_ecs_instance;
select
instance_id,
name,
arn,
status,
instance_type,
os_name_en,
public_ip_address,
private_ip_address,
zone
from
alicloud_ecs_instance;

List stopped instances that you are still being charged for

This query is useful for identifying instances that are in a stopped state but still incurring charges. It helps in managing costs by pinpointing areas where resources are not being optimally used.

select
instance_id,
name,
status,
stopped_mode,
instance_type,
os_name_en,
public_ip_address,
private_ip_address,
zone
from
alicloud_ecs_instance
where
stopped_mode = 'KeepCharging';
select
instance_id,
name,
status,
stopped_mode,
instance_type,
os_name_en,
public_ip_address,
private_ip_address,
zone
from
alicloud_ecs_instance
where
stopped_mode = 'KeepCharging';

List linux instances

Identify instances where the operating system is Linux. This is useful for managing resources or troubleshooting specific issues related to Linux-based instances.

select
instance_id,
name,
instance_type,
os_name_en,
zone
from
alicloud_ecs_instance
where
os_type = 'linux';
select
instance_id,
name,
instance_type,
os_name_en,
zone
from
alicloud_ecs_instance
where
os_type = 'linux';

Instance count in each zone

Determine the distribution of instances across various zones to balance and optimize resource allocation. This aids in planning infrastructure decisions and mitigating risk by avoiding over-reliance on a single zone.

select
zone as az,
count(*)
from
alicloud_ecs_instance
group by
zone;
select
zone as az,
count(*)
from
alicloud_ecs_instance
group by
zone;

Count the number of instances by instance type

Assess the distribution of different instance types within your Alicloud Elastic Compute Service to better understand your resource usage. This can aid in optimizing your allocation strategy and managing costs more effectively.

select
instance_type,
count(instance_type) as count
from
alicloud_ecs_instance
group by
instance_type;
select
instance_type,
count(instance_type) as count
from
alicloud_ecs_instance
group by
instance_type;

List of instances without application tag key

Identify instances where the 'application' tag key is missing, which could indicate a lack of necessary metadata for proper resource management and classification. This can be crucial for maintaining organized and efficient infrastructure in a cloud environment.

select
instance_id,
tags
from
alicloud_ecs_instance
where
tags ->> 'application' is null;
select
instance_id,
tags
from
alicloud_ecs_instance
where
json_extract(tags, '$.application') is null;

List of ECS instances provisioned with undesired(for example ecs.t5-lc2m1.nano and ecs.t6-c2m1.large is desired) instance type(s)

Identify instances where ECS instances are provisioned with undesired types, helping to manage resources and maintain preferred configurations.

select
instance_type,
count(*) as count
from
alicloud_ecs_instance
where
instance_type not in ('ecs.t5-lc2m1.nano', 'ecs.t6-c2m1.large')
group by
instance_type;
select
instance_type,
count(*) as count
from
alicloud_ecs_instance
where
instance_type not in ('ecs.t5-lc2m1.nano', 'ecs.t6-c2m1.large')
group by
instance_type;

List ECS instances having deletion protection safety feature disabled

Determine the areas in which Elastic Compute Service (ECS) instances might be at risk due to disabled deletion protection. This query is useful to identify potential vulnerabilities and ensure data safety.

select
instance_id,
deletion_protection
from
alicloud_ecs_instance
where
not deletion_protection;
select
instance_id,
deletion_protection
from
alicloud_ecs_instance
where
deletion_protection = 0;

Schema for alicloud_ecs_instance

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
account_idtext=, !=, ~~, ~~*, !~~, !~~*The Alicloud Account ID in which the resource is located.
activation_idtextThe activation Id if the instance.
agent_versiontextThe agent version.
akasjsonbArray of globally unique identifier strings (also known as) for the resource.
arntextThe Alibaba Cloud Resource Name (ARN) of the ECS instance.
auto_release_timetimestamp with time zoneThe automatic release time of the pay-as-you-go instance.
billing_methodtext=The billing method for network usage.
connectedbooleanIndicates whether the instance is connected..
cpubigintThe number of vCPUs.
cpu_options_core_countbigintThe number of CPU cores.
cpu_options_numatextThe number of threads allocated.
cpu_options_threads_per_corebigintThe number of threads per core.
creation_timetimestamp with time zoneThe time when the instance was created.
credit_specificationtextThe performance mode of the burstable instance.
dedicated_host_cluster_idtextThe cluster ID of the dedicated host.
dedicated_host_idtextThe ID of the dedicated host.
dedicated_host_nametextThe name of the dedicated host.
dedicated_instance_affinitytextIndicates whether the instance on a dedicated host is associated with the dedicated host.
dedicated_instance_tenancytextIndicates whether the instance is hosted on a dedicated host.
deletion_protectionbooleanIndicates whether you can use the ECS console or call the DeleteInstance operation to release the instance.
deployment_set_group_nobigintThe group No. of the instance in a deployment set when the deployment set is used to distribute instances across multiple physical machines.
deployment_set_idtextThe ID of the deployment set.
descriptiontextThe description of the instance.
device_availableboolean!=, =Indicates whether data disks can be attached to the instance.
ecs_capacity_reservation_idtextThe ID of the capacity reservation.
ecs_capacity_reservation_preferencetextThe preference of the ECS capacity reservation.
eip_addressjsonbThe information of the EIP associated with the instance.
expired_timetimestamp with time zoneThe expiration time of the instance.
familytext=The instance family of the instance.
gpu_amountbigintThe number of GPUs for the instance type.
gpu_spectextThe category of GPUs for the instance type.
host_nametextThe hostname of the instance.
hpc_cluster_idtextThe ID of the HPC cluster to which the instance belongs.
image_idtext=The ID of the image that the instance is running.
inner_ip_addressjsonbThe internal IP addresses of classic network-type instances. This parameter takes effect when InstanceNetworkType is set to classic. The value can be a JSON array that consists of up to 100 IP addresses. Separate multiple IP addresses with commas (,).
instance_idtext=The ID of the instance.
instance_network_typetext=The network type of the instance.
instance_typetext=The type of the instance.
internet_charge_typetext=The billing method for network usage. Valid values:PayByBandwidth,PayByTraffic
internet_max_bandwidth_inbigintThe maximum inbound bandwidth from the Internet (in Mbit/s).
internet_max_bandwidth_outbigintThe maximum outbound bandwidth to the Internet (in Mbit/s).
invocation_countbigintThe count of instance invocation
io_optimizedboolean!=, =Specifies whether the instance is I/O optimized.
is_spotbooleanIndicates whether the instance is a spot instance, or not.
key_pair_nametextThe name of the SSH key pair for the instance.
last_invoked_timetimestamp with time zoneThe time when the instance is last invoked.
local_storage_amountbigintThe number of local disks attached to the instance.
local_storage_capacitybigintThe capacity of local disks attached to the instance.
memorybigintThe memory size of the instance (in MiB).
metadata_optionsjsonbThe collection of metadata options.
nametext=The name of the instance.
network_interfacesjsonbDetails about the ENIs bound to the instance.
network_typetextThe type of the network.
operation_locksjsonbDetails about the reasons why the instance was locked.
os_nametextThe name of the operating system for the instance.
os_name_entextThe English name of the operating system for the instance.
os_typetextThe type of the operating system. Possible values are: windows and linux.
os_versiontextThe version of the operating system.
private_ip_addressjsonbThe private IP addresses of instances.
public_ip_addressjsonbThe public IP addresses of instances.
ram_rolejsonbRAM role attached to the instance.
rdma_ip_addressjsonbThe RDMA IP address of HPC instance.
recyclablebooleanIndicates whether the instance can be recycled.
regiontextThe Alicloud region in which the resource is located.
registration_timetimestamp with time zoneThe time when the instance is registered.
resource_group_idtext=The ID of the resource group to which the instance belongs.
sale_cycletextThe billing cycle of the instance.
security_group_idsjsonbThe IDs of security groups to which the instance belongs.
serial_numbertextThe serial number of the instance.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
spot_durationbigintThe protection period of the preemptible instance (in hours).
spot_price_limitdouble precisionThe maximum hourly price for the instance.
spot_strategytextThe preemption policy for the pay-as-you-go instance.
start_timetimestamp with time zoneThe start time of the bidding mode for the preemptible instance.
statustext=The status of the instance. Possible values are: Pending, Running, Starting, Stopping, and Stopped
stopped_modetextIndicates whether the instance continues to be billed after it is stopped.
tagsjsonbA map of tags for the resource.
tags_srcjsonbA list of tags attached with the resource.
titletextTitle of the resource.
vlan_idtextThe VLAN ID of the instance.
vpc_attributesjsonbThe VPC attributes of the instance.
vpc_idtext=The type of the instance.
zonetext=The zone in which the instance resides.

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_instance