steampipe plugin install aws

Table: aws_ec2_autoscaling_group - Query AWS EC2 Auto Scaling Groups using SQL

The AWS EC2 Auto Scaling Groups service allows you to ensure that you have the correct number of Amazon EC2 instances available to handle the load for your applications. Auto Scaling Groups contain a collection of EC2 instances that share similar characteristics and are treated as a logical grouping for the purposes of instance scaling and management. This service automatically increases or decreases the number of instances depending on the demand, ensuring optimal performance and cost management.

Table Usage Guide

The aws_ec2_autoscaling_group table in Steampipe provides you with information about Auto Scaling Groups within AWS EC2. This table allows you, as a DevOps engineer, to query group-specific details, including configuration, associated instances, scaling policies, and associated metadata. You can utilize this table to gather insights on groups, such as their desired, minimum and maximum sizes, default cooldown periods, load balancer names, and more. The schema outlines for you the various attributes of the Auto Scaling Group, including the ARN, creation date, health check type and grace period, launch configuration name, and associated tags.

Examples

Basic info

Explore the configuration of your AWS EC2 autoscaling group to understand its operational parameters, such as the default cooldown period and size limitations. This can help you optimize resource allocation and improve cost efficiency in your cloud environment.

select
name,
load_balancer_names,
availability_zones,
service_linked_role_arn,
default_cooldown,
max_size,
min_size,
new_instances_protected_from_scale_in
from
aws_ec2_autoscaling_group;
select
name,
load_balancer_names,
availability_zones,
service_linked_role_arn,
default_cooldown,
max_size,
min_size,
new_instances_protected_from_scale_in
from
aws_ec2_autoscaling_group;

Autoscaling groups with availability zone count less than 2

Identify autoscaling groups that may not be optimally configured for high availability due to having less than two availability zones. This can be useful to improve fault tolerance and ensure uninterrupted service.

select
name,
jsonb_array_length(availability_zones) as az_count
from
aws_ec2_autoscaling_group
where
jsonb_array_length(availability_zones) < 2;
select
name,
json_array_length(availability_zones) as az_count
from
aws_ec2_autoscaling_group
where
json_array_length(availability_zones) < 2;

Instances' information attached to the autoscaling group

Explore the health and configuration status of instances within an autoscaling group. This is useful to monitor and manage the scalability and availability of your AWS EC2 resources.

select
name as autoscaling_group_name,
ins_detail ->> 'InstanceId' as instance_id,
ins_detail ->> 'InstanceType' as instance_type,
ins_detail ->> 'AvailabilityZone' as az,
ins_detail ->> 'HealthStatus' as health_status,
ins_detail ->> 'LaunchConfigurationName' as launch_configuration_name,
ins_detail -> 'LaunchTemplate' ->> 'LaunchTemplateName' as launch_template_name,
ins_detail -> 'LaunchTemplate' ->> 'Version' as launch_template_version,
ins_detail ->> 'ProtectedFromScaleIn' as protected_from_scale_in
from
aws_ec2_autoscaling_group,
jsonb_array_elements(instances) as ins_detail;
select
name as autoscaling_group_name,
json_extract(ins_detail, '$.InstanceId') as instance_id,
json_extract(ins_detail, '$.InstanceType') as instance_type,
json_extract(ins_detail, '$.AvailabilityZone') as az,
json_extract(ins_detail, '$.HealthStatus') as health_status,
json_extract(ins_detail, '$.LaunchConfigurationName') as launch_configuration_name,
json_extract(ins_detail, '$.LaunchTemplate.LaunchTemplateName') as launch_template_name,
json_extract(ins_detail, '$.LaunchTemplate.Version') as launch_template_version,
json_extract(ins_detail, '$.ProtectedFromScaleIn') as protected_from_scale_in
from
aws_ec2_autoscaling_group,
json_each(instances) as ins_detail;

Auto scaling group health check info

Explore the health check settings of your auto scaling groups to understand their operational readiness and grace periods. This can help you assess the resilience of your system and plan for contingencies.

select
name,
health_check_type,
health_check_grace_period
from
aws_ec2_autoscaling_group;
select
name,
health_check_type,
health_check_grace_period
from
aws_ec2_autoscaling_group;

Schema for aws_ec2_autoscaling_group

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
account_idtext=, !=, ~~, ~~*, !~~, !~~*The AWS Account ID in which the resource is located.
akasjsonbArray of globally unique identifier strings (also known as) for the resource.
autoscaling_group_arntextThe Amazon Resource Name (ARN) of the Auto Scaling group.
availability_zonesjsonbOne or more Availability Zones for the group.
capacity_rebalancebooleanIndicates whether Capacity Rebalancing is enabled.
created_timetimestamp with time zoneThe date and time group was created.
default_cooldownbigintThe duration of the default cooldown period, in seconds.
default_instance_warmupbigintThe duration of the default instance warmup, in seconds.
desired_capacitybigintThe desired size of the group.
desired_capacity_typetext The unit of measurement for the value specified for desired capacity.
enabled_metricsjsonbThe metrics enabled for the group.
health_check_grace_periodbigintThe amount of time, in seconds, that Amazon EC2 Auto Scaling waits before checking the health status of an EC2 instance that has come into service.
health_check_typetextThe service to use for the health checks. The valid values are EC2 and ELB. If you configure an Auto Scaling group to use ELB health checks, it considers the instance unhealthy if it fails either the EC2 status checks or the load balancer health checks.
instance_maintenance_policyjsonbAn instance maintenance policy.
instancesjsonbThe EC2 instances associated with the group.
launch_configuration_nametextThe name of the associated launch configuration.
launch_template_idtextThe ID of the launch template.
launch_template_nametextThe launch template name for the group.
launch_template_versiontextThe version number, $Latest, or $Default.
load_balancer_namesjsonbOne or more load balancers associated with the group.
max_instance_lifetimebigintThe maximum amount of time, in seconds, that an instance can be in service.
max_sizebigintThe maximum size of the group.
min_sizebigintThe minimum size of the group.
mixed_instances_policy_launch_template_idtextThe name of the launch template for mixed instances policy.
mixed_instances_policy_launch_template_nametextThe ID of the launch template for mixed instances policy.
mixed_instances_policy_launch_template_overridesjsonbAny parameters that is specified in the list override the same parameters in the launch template.
mixed_instances_policy_launch_template_versiontextThe version of the launch template for mixed instances policy.
nametext=The name of the Auto Scaling group.
new_instances_protected_from_scale_inbooleanIndicates whether newly launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in.
on_demand_allocation_strategytextIndicates how to allocate instance types to fulfill On-Demand capacity. The only valid value is prioritized, which is also the default value. This strategy uses the order of instance types in the overrides to define the launch priority of each instance type.
on_demand_base_capacitybigintThe minimum amount of the Auto Scaling group's capacity that must be fulfilled by On-Demand Instances. This base portion is provisioned first as group scales. Defaults to 0 if not specified.
on_demand_percentage_above_base_capacitybigintControls the percentages of On-Demand Instances and Spot Instances for your additional capacity beyond OnDemandBaseCapacity. Expressed as a number (for example, 20 specifies 20% On-Demand Instances, 80% Spot Instances). Defaults to 100 if not specified. If set to 100, only On-Demand Instances are provisioned.
partitiontextThe AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov).
placement_grouptextThe name of the placement group into which to launch your instances, if any.
policiesjsonbA set of scaling policies for the specified Auto Scaling group.
regiontextThe AWS Region in which the resource is located.
service_linked_role_arntextThe Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling group uses to call other AWS services on your behalf.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
spot_allocation_strategytextIndicates how to allocate instances across Spot Instance pools. If the allocation strategy is lowest-price, the Auto Scaling group launches instances using the Spot pools with the lowest price, and evenly allocates your instances across the number of Spot pools that you specify. If the allocation strategy is capacity-optimized, the Auto Scaling group launches instances using Spot pools that are optimally chosen based on the available Spot capacity. Defaults to lowest-price if not specified.
spot_instance_poolsbigintThe number of Spot Instance pools across which to allocate your Spot Instances.
spot_max_pricetextThe maximum price per unit hour that user is willing to pay for a Spot Instance. If the value of this parameter is blank (which is the default), the maximum Spot price is set at the On-Demand price.
statustextThe current state of the group when the DeleteAutoScalingGroup operation is in progress.
suspended_processesjsonbThe suspended processes associated with the group.
tagsjsonbA map of tags for the resource.
tags_srcjsonbA list of tags assigned to the Auto Scaling Group.
target_group_arnsjsonbThe Amazon Resource Names (ARN) of the target groups for your load balancer.
termination_policiesjsonbThe termination policies for the group.
titletextTitle of the resource.
traffic_sourcesjsonbThe traffic sources associated with this Auto Scaling group.
vpc_zone_identifiertextOne or more subnet IDs, if applicable, separated by commas.
warm_pool_configurationjsonbThe warm pool for the group.
warm_pool_sizebigintThe current size of the warm pool.

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

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

steampipe_export_aws --config '<your_config>' aws_ec2_autoscaling_group