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_infrom 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_infrom 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_countfrom aws_ec2_autoscaling_groupwhere jsonb_array_length(availability_zones) < 2;
select name, json_array_length(availability_zones) as az_countfrom aws_ec2_autoscaling_groupwhere 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_infrom 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_infrom 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_periodfrom aws_ec2_autoscaling_group;
select name, health_check_type, health_check_grace_periodfrom aws_ec2_autoscaling_group;
Schema for aws_ec2_autoscaling_group
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The AWS Account ID in which the resource is located. |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
autoscaling_group_arn | text | The Amazon Resource Name (ARN) of the Auto Scaling group. | |
availability_zones | jsonb | One or more Availability Zones for the group. | |
capacity_rebalance | boolean | Indicates whether Capacity Rebalancing is enabled. | |
created_time | timestamp with time zone | The date and time group was created. | |
default_cooldown | bigint | The duration of the default cooldown period, in seconds. | |
default_instance_warmup | bigint | The duration of the default instance warmup, in seconds. | |
desired_capacity | bigint | The desired size of the group. | |
desired_capacity_type | text | The unit of measurement for the value specified for desired capacity. | |
enabled_metrics | jsonb | The metrics enabled for the group. | |
health_check_grace_period | bigint | The 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_type | text | The 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_policy | jsonb | An instance maintenance policy. | |
instances | jsonb | The EC2 instances associated with the group. | |
launch_configuration_name | text | The name of the associated launch configuration. | |
launch_template_id | text | The ID of the launch template. | |
launch_template_name | text | The launch template name for the group. | |
launch_template_version | text | The version number, $Latest, or $Default. | |
load_balancer_names | jsonb | One or more load balancers associated with the group. | |
max_instance_lifetime | bigint | The maximum amount of time, in seconds, that an instance can be in service. | |
max_size | bigint | The maximum size of the group. | |
min_size | bigint | The minimum size of the group. | |
mixed_instances_policy_launch_template_id | text | The name of the launch template for mixed instances policy. | |
mixed_instances_policy_launch_template_name | text | The ID of the launch template for mixed instances policy. | |
mixed_instances_policy_launch_template_overrides | jsonb | Any parameters that is specified in the list override the same parameters in the launch template. | |
mixed_instances_policy_launch_template_version | text | The version of the launch template for mixed instances policy. | |
name | text | = | The name of the Auto Scaling group. |
new_instances_protected_from_scale_in | boolean | Indicates whether newly launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in. | |
on_demand_allocation_strategy | text | Indicates 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_capacity | bigint | The 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_capacity | bigint | Controls 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. | |
partition | text | The AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov). | |
placement_group | text | The name of the placement group into which to launch your instances, if any. | |
policies | jsonb | A set of scaling policies for the specified Auto Scaling group. | |
region | text | The AWS Region in which the resource is located. | |
service_linked_role_arn | text | The 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_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
spot_allocation_strategy | text | Indicates 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_pools | bigint | The number of Spot Instance pools across which to allocate your Spot Instances. | |
spot_max_price | text | The 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. | |
status | text | The current state of the group when the DeleteAutoScalingGroup operation is in progress. | |
suspended_processes | jsonb | The suspended processes associated with the group. | |
tags | jsonb | A map of tags for the resource. | |
tags_src | jsonb | A list of tags assigned to the Auto Scaling Group. | |
target_group_arns | jsonb | The Amazon Resource Names (ARN) of the target groups for your load balancer. | |
termination_policies | jsonb | The termination policies for the group. | |
title | text | Title of the resource. | |
traffic_sources | jsonb | The traffic sources associated with this Auto Scaling group. | |
vpc_zone_identifier | text | One or more subnet IDs, if applicable, separated by commas. | |
warm_pool_configuration | jsonb | The warm pool for the group. | |
warm_pool_size | bigint | The 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