Skip to main content

auto_scaling_groups

Creates, updates, deletes, gets or lists an auto_scaling_groups resource.

Overview

Nameauto_scaling_groups
TypeResource
Idaws.autoscaling.auto_scaling_groups

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
auto_scaling_group_arnstringThe Amazon Resource Name (ARN) of the Auto Scaling group.
auto_scaling_group_namestringThe name of the Auto Scaling group.
availability_zone_distributionstringThe EC2 instance capacity distribution across Availability Zones for the Auto Scaling group.
availability_zone_idsstringThe Availability Zone IDs where the Auto Scaling group can launch instances.
availability_zone_impairment_policystringThe Availability Zone impairment policy for the Auto Scaling group.
availability_zonesstringOne or more Availability Zones for the Auto Scaling group.
capacity_rebalancebooleanIndicates whether Capacity Rebalancing is enabled.
capacity_reservation_specificationstringThe capacity reservation specification for the Auto Scaling group.
contextstringReserved.
created_timestringThe date and time the Auto Scaling group was created.
default_cooldownintegerThe duration of the default cooldown period, in seconds, for the Auto Scaling group.
default_instance_warmupintegerThe duration of the default EC2 instance warmup time, in seconds, for the Auto Scaling group.
deletion_protectionstringThe deletion protection setting for the Auto Scaling group.
desired_capacityintegerThe desired size of the Auto Scaling group.
desired_capacity_typestringThe unit of measurement for the value specified for desired capacity. Amazon EC2 Auto Scaling supports DesiredCapacityType for attribute-based instance type selection only.
enabled_metricsstringThe metrics enabled for the Auto Scaling group.
health_check_grace_periodintegerThe duration of the health check grace period, in seconds, for the Auto Scaling group.
health_check_typestringOne or more comma-separated health check types for the Auto Scaling group.
instance_lifecycle_policystringThe instance lifecycle policy for the Auto Scaling group.
instance_maintenance_policystringAn instance maintenance policy.
instancesstringThe EC2 instances associated with the Auto Scaling group.
launch_configuration_namestringThe name of the associated launch configuration for the Auto Scaling group.
launch_templatestringThe launch template for the Auto Scaling group.
load_balancer_namesstringOne or more load balancers associated with the group.
max_instance_lifetimeintegerThe maximum amount of time, in seconds, that an EC2 instance can be in service for the Auto Scaling group.
max_sizeintegerThe maximum size of the Auto Scaling group.
min_sizeintegerThe minimum size of the Auto Scaling group.
mixed_instances_policystringThe mixed instances policy for the group.
new_instances_protected_from_scale_inbooleanIndicates whether newly launched EC2 instances are protected from termination when scaling in for the Auto Scaling group. For more information about preventing instances from terminating on scale in, see Use instance scale-in protection in the Amazon EC2 Auto Scaling User Guide.
operatorstringThe entity that manages the Auto Scaling group, if applicable. When set, only the designated operator can make changes to the group configuration.
placement_groupstringThe name of the placement group into which to launch EC2 instances for the Auto Scaling group.
predicted_capacityintegerThe predicted capacity of the group when it has a predictive scaling policy.
service_linked_role_arnstringThe Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling group uses to call other Amazon Web Services on your behalf.
statusstringThe current state of the Auto Scaling group when the DeleteAutoScalingGroup operation is in progress.
suspended_processesstringThe suspended processes associated with the Auto Scaling group.
tagsstringThe tags for the Auto Scaling group.
target_group_arnsstringThe Amazon Resource Names (ARN) of the target groups for your load balancer.
termination_policiesstringThe termination policies for the Auto Scaling group.
traffic_sourcesstringThe traffic sources associated with this Auto Scaling group.
vpc_zone_identifierstringOne or more comma-separated subnet IDs for the Auto Scaling group.
warm_pool_configurationstringThe warm pool for the group.
warm_pool_sizeintegerThe current size of the warm pool.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_auto_scaling_groupsselectregionAutoScalingGroupNames, IncludeInstances, NextToken, MaxRecords, FiltersGets information about the Auto Scaling groups in the account and Region. If you specify Auto Scaling group names, the output includes information for only the specified Auto Scaling groups. If you specify filters, the output includes information for only those Auto Scaling groups that meet the filter criteria. If you do not specify group names or filters, the output includes information for all Auto Scaling groups. This operation also returns information about instances in Auto Scaling groups. To retrieve information about the instances in a warm pool, you must call the DescribeWarmPool API.
create_auto_scaling_groupinsertAutoScalingGroupName, MinSize, MaxSize, regionLaunchConfigurationName, LaunchTemplate, MixedInstancesPolicy, InstanceId, DesiredCapacity, DefaultCooldown, AvailabilityZones, AvailabilityZoneIds, LoadBalancerNames, TargetGroupARNs, HealthCheckType, HealthCheckGracePeriod, PlacementGroup, VPCZoneIdentifier, TerminationPolicies, NewInstancesProtectedFromScaleIn, CapacityRebalance, LifecycleHookSpecificationList, DeletionProtection, Tags, ServiceLinkedRoleARN, MaxInstanceLifetime, Context, DesiredCapacityType, DefaultInstanceWarmup, TrafficSources, InstanceMaintenancePolicy, AvailabilityZoneDistribution, AvailabilityZoneImpairmentPolicy, SkipZonalShiftValidation, CapacityReservationSpecification, InstanceLifecyclePolicy, OperatorWe strongly recommend using a launch template when calling this operation to ensure full functionality for Amazon EC2 Auto Scaling and Amazon EC2. Creates an Auto Scaling group with the specified name and attributes. If you exceed your maximum limit of Auto Scaling groups, the call fails. To query this limit, call the DescribeAccountLimits API. For information about updating this limit, see Quotas for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide. If you're new to Amazon EC2 Auto Scaling, see the introductory tutorials in Get started with Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide. Every Auto Scaling group has three size properties (DesiredCapacity, MaxSize, and MinSize). Usually, you set these sizes based on a specific number of instances. However, if you configure a mixed instances policy that defines weights for the instance types, you must specify these sizes with the same units that you use for weighting instances.
set_instance_protectionupdateInstanceIds, AutoScalingGroupName, ProtectedFromScaleIn, regionUpdates the instance protection settings of the specified instances. This operation cannot be called on instances in a warm pool. For more information, see Use instance scale-in protection in the Amazon EC2 Auto Scaling User Guide. If you exceed your maximum limit of instance IDs, which is 50 per Auto Scaling group, the call fails.
detach_instancesupdateAutoScalingGroupName, ShouldDecrementDesiredCapacity, regionInstanceIdsRemoves one or more instances from the specified Auto Scaling group. After the instances are detached, you can manage them independent of the Auto Scaling group. If you do not specify the option to decrement the desired capacity, Amazon EC2 Auto Scaling launches instances to replace the ones that are detached. If there is a Classic Load Balancer attached to the Auto Scaling group, the instances are deregistered from the load balancer. If there are target groups attached to the Auto Scaling group, the instances are deregistered from the target groups. For more information, see Detach or attach instances in the Amazon EC2 Auto Scaling User Guide.
set_desired_capacityupdateAutoScalingGroupName, DesiredCapacity, regionHonorCooldownSets the size of the specified Auto Scaling group. If a scale-in activity occurs as a result of a new DesiredCapacity value that is lower than the current size of the group, the Auto Scaling group uses its termination policy to determine which instances to terminate. For more information, see Manual scaling in the Amazon EC2 Auto Scaling User Guide.
update_auto_scaling_groupupdateAutoScalingGroupName, regionLaunchConfigurationName, LaunchTemplate, MixedInstancesPolicy, MinSize, MaxSize, DesiredCapacity, DefaultCooldown, AvailabilityZones, AvailabilityZoneIds, HealthCheckType, HealthCheckGracePeriod, PlacementGroup, VPCZoneIdentifier, TerminationPolicies, NewInstancesProtectedFromScaleIn, ServiceLinkedRoleARN, MaxInstanceLifetime, CapacityRebalance, Context, DesiredCapacityType, DefaultInstanceWarmup, InstanceMaintenancePolicy, AvailabilityZoneDistribution, AvailabilityZoneImpairmentPolicy, SkipZonalShiftValidation, CapacityReservationSpecification, InstanceLifecyclePolicy, DeletionProtectionWe strongly recommend that all Auto Scaling groups use launch templates to ensure full functionality for Amazon EC2 Auto Scaling and Amazon EC2. Updates the configuration for the specified Auto Scaling group. To update an Auto Scaling group, specify the name of the group and the property that you want to change. Any properties that you don't specify are not changed by this update request. The new settings take effect on any scaling activities after this call returns. If you associate a new launch configuration or template with an Auto Scaling group, all new instances will get the updated configuration. Existing instances continue to run with the configuration that they were originally launched with. When you update a group to specify a mixed instances policy instead of a launch configuration or template, existing instances may be replaced to match the new purchasing options that you specified in the policy. For example, if the group currently has 100% On-Demand capacity and the policy specifies 50% Spot capacity, this means that half of your instances will be gradually terminated and relaunched as Spot Instances. When replacing instances, Amazon EC2 Auto Scaling launches new instances before terminating the old ones, so that updating your group does not compromise the performance or availability of your application. Note the following about changing DesiredCapacity, MaxSize, or MinSize: If a scale-in activity occurs as a result of a new DesiredCapacity value that is lower than the current size of the group, the Auto Scaling group uses its termination policy to determine which instances to terminate. If you specify a new value for MinSize without specifying a value for DesiredCapacity, and the new MinSize is larger than the current size of the group, this sets the group's DesiredCapacity to the new MinSize value. If you specify a new value for MaxSize without specifying a value for DesiredCapacity, and the new MaxSize is smaller than the current size of the group, this sets the group's DesiredCapacity to the new MaxSize value. To see which properties have been set, call the DescribeAutoScalingGroups API. To view the scaling policies for an Auto Scaling group, call the DescribePolicies API. If the group has scaling policies, you can update them by calling the PutScalingPolicy API.
put_scheduled_update_group_actionreplaceAutoScalingGroupName, ScheduledActionName, regionTime, StartTime, EndTime, Recurrence, MinSize, MaxSize, DesiredCapacity, TimeZoneCreates or updates a scheduled scaling action for an Auto Scaling group. For more information, see Scheduled scaling in the Amazon EC2 Auto Scaling User Guide. You can view the scheduled actions for an Auto Scaling group using the DescribeScheduledActions API call. If you are no longer using a scheduled action, you can delete it by calling the DeleteScheduledAction API. If you try to schedule your action in the past, Amazon EC2 Auto Scaling returns an error message.
delete_auto_scaling_groupdeleteAutoScalingGroupName, regionForceDeleteDeletes the specified Auto Scaling group. If the group has instances or scaling activities in progress, you must specify the option to force the deletion in order for it to succeed. The force delete operation will also terminate the EC2 instances. If the group has a warm pool, the force delete option also deletes the warm pool. To remove instances from the Auto Scaling group before deleting it, call the DetachInstances API with the list of instances and the option to decrement the desired capacity. This ensures that Amazon EC2 Auto Scaling does not launch replacement instances. To terminate all instances before deleting the Auto Scaling group, call the UpdateAutoScalingGroup API and set the minimum size and desired capacity of the Auto Scaling group to zero. If the group has scaling policies, deleting the group deletes the policies, the underlying alarm actions, and any alarm that no longer has an associated action. For more information, see Delete your Auto Scaling infrastructure in the Amazon EC2 Auto Scaling User Guide.
terminate_instance_in_auto_scaling_groupdeleteShouldDecrementDesiredCapacity, regionInstanceId, InstanceIds, AutoScalingGroupNameTerminates the specified instance and optionally adjusts the desired group size. This operation cannot be called on instances in a warm pool. This call simply makes a termination request. The instances are not terminated immediately. When an instance is terminated, the instance status changes to terminated. You can't connect to or start an instance after you've terminated it. If you do not specify the option to decrement the desired capacity, Amazon EC2 Auto Scaling launches instances to replace the ones that are terminated. To terminate multiple instances in a single call, use the InstanceIds and AutoScalingGroupName parameters instead of InstanceId. When terminating multiple instances, the response populates Activities instead of Activity. By default, Amazon EC2 Auto Scaling balances instances across all Availability Zones. If you decrement the desired capacity, your Auto Scaling group can become unbalanced between Availability Zones. Amazon EC2 Auto Scaling tries to rebalance the group, and rebalancing might terminate instances in other zones. For more information, see Manual scaling in the Amazon EC2 Auto Scaling User Guide.
attach_instancesexecAutoScalingGroupName, regionInstanceIdsAttaches one or more EC2 instances to the specified Auto Scaling group. When you attach instances, Amazon EC2 Auto Scaling increases the desired capacity of the group by the number of instances being attached. If the number of instances being attached plus the desired capacity of the group exceeds the maximum size of the group, the operation fails. If there is a Classic Load Balancer attached to your Auto Scaling group, the instances are also registered with the load balancer. If there are target groups attached to your Auto Scaling group, the instances are also registered with the target groups. For more information, see Detach or attach instances in the Amazon EC2 Auto Scaling User Guide.
batch_delete_scheduled_actionexecAutoScalingGroupName, ScheduledActionNames, regionDeletes one or more scheduled actions for the specified Auto Scaling group.
batch_put_scheduled_update_group_actionexecAutoScalingGroupName, ScheduledUpdateGroupActions, regionCreates or updates one or more scheduled scaling actions for an Auto Scaling group.
cancel_instance_refreshexecAutoScalingGroupName, regionWaitForTransitioningInstancesCancels an instance refresh or rollback that is in progress. If an instance refresh or rollback is not in progress, an ActiveInstanceRefreshNotFound error occurs. This operation is part of the instance refresh feature in Amazon EC2 Auto Scaling, which helps you update instances in your Auto Scaling group after you make configuration changes. When you cancel an instance refresh, this does not roll back any changes that it made. Use the RollbackInstanceRefresh API to roll back instead.
complete_lifecycle_actionexecLifecycleHookName, AutoScalingGroupName, LifecycleActionResult, regionLifecycleActionToken, InstanceIdCompletes the lifecycle action for the specified token or instance with the specified result. This step is a part of the procedure for adding a lifecycle hook to an Auto Scaling group: (Optional) Create a launch template or launch configuration with a user data script that runs while an instance is in a wait state due to a lifecycle hook. (Optional) Create a Lambda function and a rule that allows Amazon EventBridge to invoke your Lambda function when an instance is put into a wait state due to a lifecycle hook. (Optional) Create a notification target and an IAM role. The target can be either an Amazon SQS queue or an Amazon SNS topic. The role allows Amazon EC2 Auto Scaling to publish lifecycle notifications to the target. Create the lifecycle hook. Specify whether the hook is used when the instances launch or terminate. If you need more time, record the lifecycle action heartbeat to keep the instance in a wait state. If you finish before the timeout period ends, send a callback by using the CompleteLifecycleAction API call. For more information, see Complete a lifecycle action in the Amazon EC2 Auto Scaling User Guide.
disable_metrics_collectionexecAutoScalingGroupName, regionMetricsDisables group metrics collection for the specified Auto Scaling group.
enable_metrics_collectionexecAutoScalingGroupName, Granularity, regionMetricsEnables group metrics collection for the specified Auto Scaling group. You can use these metrics to track changes in an Auto Scaling group and to set alarms on threshold values. You can view group metrics using the Amazon EC2 Auto Scaling console or the CloudWatch console. For more information, see Monitor CloudWatch metrics for your Auto Scaling groups and instances in the Amazon EC2 Auto Scaling User Guide.
enter_standbyexecAutoScalingGroupName, ShouldDecrementDesiredCapacity, regionInstanceIdsMoves the specified instances into the standby state. If you choose to decrement the desired capacity of the Auto Scaling group, the instances can enter standby as long as the desired capacity of the Auto Scaling group after the instances are placed into standby is equal to or greater than the minimum capacity of the group. If you choose not to decrement the desired capacity of the Auto Scaling group, the Auto Scaling group launches new instances to replace the instances on standby. For more information, see Temporarily removing instances from your Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.
exit_standbyexecAutoScalingGroupName, regionInstanceIdsMoves the specified instances out of the standby state. After you put the instances back in service, the desired capacity is incremented. For more information, see Temporarily removing instances from your Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.
launch_instancesexecAutoScalingGroupName, RequestedCapacity, ClientToken, regionAvailabilityZones, AvailabilityZoneIds, SubnetIds, RetryStrategyLaunches a specified number of instances in an Auto Scaling group. Returns instance IDs and other details if launch is successful or error details if launch is unsuccessful.
record_lifecycle_action_heartbeatexecLifecycleHookName, AutoScalingGroupName, regionLifecycleActionToken, InstanceIdRecords a heartbeat for the lifecycle action associated with the specified token or instance. This extends the timeout by the length of time defined using the PutLifecycleHook API call. This step is a part of the procedure for adding a lifecycle hook to an Auto Scaling group: (Optional) Create a launch template or launch configuration with a user data script that runs while an instance is in a wait state due to a lifecycle hook. (Optional) Create a Lambda function and a rule that allows Amazon EventBridge to invoke your Lambda function when an instance is put into a wait state due to a lifecycle hook. (Optional) Create a notification target and an IAM role. The target can be either an Amazon SQS queue or an Amazon SNS topic. The role allows Amazon EC2 Auto Scaling to publish lifecycle notifications to the target. Create the lifecycle hook. Specify whether the hook is used when the instances launch or terminate. If you need more time, record the lifecycle action heartbeat to keep the instance in a wait state. If you finish before the timeout period ends, send a callback by using the CompleteLifecycleAction API call. For more information, see Amazon EC2 Auto Scaling lifecycle hooks in the Amazon EC2 Auto Scaling User Guide.
resume_processesexecAutoScalingGroupName, regionScalingProcessesResumes the specified suspended auto scaling processes, or all suspended process, for the specified Auto Scaling group. For more information, see Suspend and resume Amazon EC2 Auto Scaling processes in the Amazon EC2 Auto Scaling User Guide.
rollback_instance_refreshexecAutoScalingGroupName, regionCancels an instance refresh that is in progress and rolls back any changes that it made. Amazon EC2 Auto Scaling replaces any instances that were replaced during the instance refresh. This restores your Auto Scaling group to the configuration that it was using before the start of the instance refresh. This operation is part of the instance refresh feature in Amazon EC2 Auto Scaling, which helps you update instances in your Auto Scaling group after you make configuration changes. A rollback is not supported in the following situations: There is no desired configuration specified for the instance refresh. The Auto Scaling group has a launch template that uses an Amazon Web Services Systems Manager parameter instead of an AMI ID for the ImageId property. The Auto Scaling group uses the launch template's $Latest or $Default version. When you receive a successful response from this operation, Amazon EC2 Auto Scaling immediately begins replacing instances. You can check the status of this operation through the DescribeInstanceRefreshes API operation.
start_instance_refreshexecAutoScalingGroupName, regionStrategy, DesiredConfiguration, PreferencesStarts an instance refresh. This operation is part of the instance refresh feature in Amazon EC2 Auto Scaling, which helps you update instances in your Auto Scaling group. This feature is helpful, for example, when you have a new AMI or a new user data script. You just need to create a new launch template that specifies the new AMI or user data script. Then start an instance refresh to immediately begin the process of updating instances in the group. If successful, the request's response contains a unique ID that you can use to track the progress of the instance refresh. To query its status, call the DescribeInstanceRefreshes API. To describe the instance refreshes that have already run, call the DescribeInstanceRefreshes API. To cancel an instance refresh that is in progress, use the CancelInstanceRefresh API. An instance refresh might fail for several reasons, such as EC2 launch failures, misconfigured health checks, or not ignoring or allowing the termination of instances that are in Standby state or protected from scale in. You can monitor for failed EC2 launches using the scaling activities. To find the scaling activities, call the DescribeScalingActivities API. If you enable auto rollback, your Auto Scaling group will be rolled back automatically when the instance refresh fails. You can enable this feature before starting an instance refresh by specifying the AutoRollback property in the instance refresh preferences. Otherwise, to roll back an instance refresh before it finishes, use the RollbackInstanceRefresh API.
suspend_processesexecAutoScalingGroupName, regionScalingProcessesSuspends the specified auto scaling processes, or all processes, for the specified Auto Scaling group. If you suspend either the Launch or Terminate process types, it can prevent other process types from functioning properly. For more information, see Suspend and resume Amazon EC2 Auto Scaling processes in the Amazon EC2 Auto Scaling User Guide. To resume processes that have been suspended, call the ResumeProcesses API.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
AutoScalingGroupNamestringThe name of the Auto Scaling group.
ClientTokenstringA unique, case-sensitive identifier to ensure idempotency of the request.
DesiredCapacityintegerThe desired capacity is the initial capacity of the Auto Scaling group after this operation completes and the capacity it attempts to maintain.
GranularitystringThe frequency at which Amazon EC2 Auto Scaling sends aggregated data to CloudWatch. The only valid value is 1Minute.
InstanceIdsarrayOne or more instance IDs. You can specify up to 50 instances.
LifecycleActionResultstringThe action for the group to take. You can specify either CONTINUE or ABANDON.
LifecycleHookNamestringThe name of the lifecycle hook.
MaxSizeintegerThe maximum size of the group. With a mixed instances policy that uses instance weighting, Amazon EC2 Auto Scaling may need to go above MaxSize to meet your capacity requirements. In this event, Amazon EC2 Auto Scaling will never go above MaxSize by more than your largest instance weight (weights that define how many units each instance contributes to the desired capacity of the group).
MinSizeintegerThe minimum size of the group.
ProtectedFromScaleInbooleanIndicates whether the instance is protected from termination by Amazon EC2 Auto Scaling when scaling in.
RequestedCapacityintegerThe number of instances to launch. Although this value can exceed 100 for instance weights, the actual instance count is limited to 100 instances per launch.
ScheduledActionNamestringThe name of this scaling action.
ScheduledActionNamesarrayThe names of the scheduled actions to delete. The maximum number allowed is 50.
ScheduledUpdateGroupActionsarrayOne or more scheduled actions. The maximum number allowed is 50.
ShouldDecrementDesiredCapacitybooleanIndicates whether to decrement the desired capacity of the Auto Scaling group by the number of instances moved to Standby mode.
regionstringAWS region (default: us-east-1)
AutoScalingGroupNamestringThe name of the Auto Scaling group. Required when using InstanceIds.
AutoScalingGroupNamesarrayThe names of the Auto Scaling groups. By default, you can only specify up to 50 names. You can optionally increase this limit using the MaxRecords property. If you omit this property, all Auto Scaling groups are described.
AvailabilityZoneDistributionobjectThe instance capacity distribution across Availability Zones.
AvailabilityZoneIdsarrayA list of Availability Zone IDs where instances should be launched. Must match or be included in the group's AZ configuration. You cannot specify both AvailabilityZones and AvailabilityZoneIds. Required for multi-AZ groups, optional for single-AZ groups.
AvailabilityZoneImpairmentPolicyobjectThe policy for Availability Zone impairment.
AvailabilityZonesarrayThe Availability Zones for the instance launch. Must match or be included in the Auto Scaling group's Availability Zone configuration. Either AvailabilityZones or SubnetIds must be specified for groups with multiple Availability Zone configurations.
CapacityRebalancebooleanEnables or disables Capacity Rebalancing. If Capacity Rebalancing is disabled, proactive replacement of at-risk Spot Instances does not occur. For more information, see Capacity Rebalancing in Auto Scaling to replace at-risk Spot Instances in the Amazon EC2 Auto Scaling User Guide. To suspend rebalancing across Availability Zones, use the SuspendProcesses API.
CapacityReservationSpecificationobjectThe capacity reservation specification for the Auto Scaling group.
ContextstringReserved.
DefaultCooldownintegerOnly needed if you use simple scaling policies. The amount of time, in seconds, between one scaling activity ending and another one starting due to simple scaling policies. For more information, see Scaling cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
DefaultInstanceWarmupintegerThe amount of time, in seconds, until a new instance is considered to have finished initializing and resource consumption to become stable after it enters the InService state. During an instance refresh, Amazon EC2 Auto Scaling waits for the warm-up period after it replaces an instance before it moves on to replacing the next instance. Amazon EC2 Auto Scaling also waits for the warm-up period before aggregating the metrics for new instances with existing instances in the Amazon CloudWatch metrics that are used for scaling, resulting in more reliable usage data. For more information, see Set the default instance warmup for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide. To manage various warm-up settings at the group level, we recommend that you set the default instance warmup, even if it is set to 0 seconds. To remove a value that you previously set, include the property but specify -1 for the value. However, we strongly recommend keeping the default instance warmup enabled by specifying a value of 0 or other nominal value.
DeletionProtectionstringThe deletion protection setting for the Auto Scaling group. This setting helps safeguard your Auto Scaling group and its instances by controlling whether the DeleteAutoScalingGroup operation is allowed. When deletion protection is enabled, users cannot delete the Auto Scaling group according to the specified protection level until the setting is changed back to a less restrictive level. The valid values are none, prevent-force-deletion, and prevent-all-deletion. Default: none For more information, see Configure deletion protection for your Amazon EC2 Auto Scaling resources in the Amazon EC2 Auto Scaling User Guide.
DesiredCapacityintegerThe desired capacity is the initial capacity of the Auto Scaling group after the scheduled action runs and the capacity it attempts to maintain. It can scale beyond this capacity if you add more scaling conditions. You must specify at least one of the following properties: MaxSize, MinSize, or DesiredCapacity.
DesiredCapacityTypestringThe unit of measurement for the value specified for desired capacity. Amazon EC2 Auto Scaling supports DesiredCapacityType for attribute-based instance type selection only. For more information, see Create a mixed instances group using attribute-based instance type selection in the Amazon EC2 Auto Scaling User Guide. By default, Amazon EC2 Auto Scaling specifies units, which translates into number of instances. Valid values: units | vcpu | memory-mib
DesiredConfigurationobjectThe desired configuration. For example, the desired configuration can specify a new launch template or a new version of the current launch template. Once the instance refresh succeeds, Amazon EC2 Auto Scaling updates the settings of the Auto Scaling group to reflect the new desired configuration. When you specify a new launch template or a new version of the current launch template for your desired configuration, consider enabling the SkipMatching property in preferences. If it's enabled, Amazon EC2 Auto Scaling skips replacing instances that already use the specified launch template and instance types. This can help you reduce the number of replacements that are required to apply updates.
EndTimestring (date-time)The date and time for the recurring schedule to end, in UTC. For example, "2021-06-01T00:00:00Z".
FiltersarrayOne or more filters to limit the results based on specific tags.
ForceDeletebooleanSpecifies that the group is to be deleted along with all instances associated with the group, without waiting for all instances to be terminated. This action also deletes any outstanding lifecycle actions associated with the group.
HealthCheckGracePeriodintegerThe 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 and marking it unhealthy due to a failed health check. This is useful if your instances do not immediately pass their health checks after they enter the InService state. For more information, see Set the health check grace period for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.
HealthCheckTypestringA comma-separated value string of one or more health check types. The valid values are EC2, EBS, ELB, and VPC_LATTICE. EC2 is the default health check and cannot be disabled. For more information, see Health checks for instances in an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide. Only specify EC2 if you must clear a value that was previously set.
HonorCooldownbooleanIndicates whether Amazon EC2 Auto Scaling waits for the cooldown period to complete before initiating a scaling activity to set your Auto Scaling group to its new capacity. By default, Amazon EC2 Auto Scaling does not honor the cooldown period during manual scaling activities.
IncludeInstancesbooleanSpecifies whether to include information about Amazon EC2 instances in the response. When set to true (default), the response includes instance details.
InstanceIdstringThe ID of the instance.
InstanceIdsarrayThe IDs of the instances. You can specify up to 20 instances.
InstanceLifecyclePolicyobjectThe instance lifecycle policy for the Auto Scaling group. This policy controls instance behavior when an instance transitions through its lifecycle states. Configure retention triggers to specify when instances should move to a Retained state instead of automatic termination. For more information, see Control instance retention with instance lifecycle policies in the Amazon EC2 Auto Scaling User Guide.
InstanceMaintenancePolicyobjectAn instance maintenance policy. For more information, see Set instance maintenance policy in the Amazon EC2 Auto Scaling User Guide.
LaunchConfigurationNamestringThe name of the launch configuration. If you specify LaunchConfigurationName in your update request, you can't specify LaunchTemplate or MixedInstancesPolicy.
LaunchTemplateobjectThe launch template and version to use to specify the updates. If you specify LaunchTemplate in your update request, you can't specify LaunchConfigurationName or MixedInstancesPolicy.
LifecycleActionTokenstringA token that uniquely identifies a specific lifecycle action associated with an instance. Amazon EC2 Auto Scaling sends this token to the notification target that you specified when you created the lifecycle hook.
LifecycleHookSpecificationListarrayOne or more lifecycle hooks to add to the Auto Scaling group before instances are launched.
LoadBalancerNamesarrayA list of Classic Load Balancers associated with this Auto Scaling group. For Application Load Balancers, Network Load Balancers, and Gateway Load Balancers, specify the TargetGroupARNs property instead.
MaxInstanceLifetimeintegerThe maximum amount of time, in seconds, that an instance can be in service. The default is null. If specified, the value must be either 0 or a number equal to or greater than 86,400 seconds (1 day). To clear a previously set value, specify a new value of 0. For more information, see Replacing Auto Scaling instances based on maximum instance lifetime in the Amazon EC2 Auto Scaling User Guide.
MaxRecordsintegerThe maximum number of items to return with this call. The default value is 50 and the maximum value is 100.
MaxSizeintegerThe maximum size of the Auto Scaling group.
MetricsarrayIdentifies the metrics to enable. You can specify one or more of the following metrics: GroupMinSize GroupMaxSize GroupDesiredCapacity GroupInServiceInstances GroupPendingInstances GroupStandbyInstances GroupTerminatingInstances GroupTotalInstances GroupInServiceCapacity GroupPendingCapacity GroupStandbyCapacity GroupTerminatingCapacity GroupTotalCapacity WarmPoolDesiredCapacity WarmPoolWarmedCapacity WarmPoolPendingCapacity WarmPoolTerminatingCapacity WarmPoolTotalCapacity GroupAndWarmPoolDesiredCapacity GroupAndWarmPoolTotalCapacity If you specify Granularity and don't specify any metrics, all metrics are enabled. For more information, see Amazon CloudWatch metrics for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
MinSizeintegerThe minimum size of the Auto Scaling group.
MixedInstancesPolicyobjectThe mixed instances policy. For more information, see Auto Scaling groups with multiple instance types and purchase options in the Amazon EC2 Auto Scaling User Guide.
NewInstancesProtectedFromScaleInbooleanIndicates whether newly launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in. For more information about preventing instances from terminating on scale in, see Use instance scale-in protection in the Amazon EC2 Auto Scaling User Guide.
NextTokenstringThe token for the next set of items to return. (You received this token from a previous call.)
OperatorobjectThe entity that manages the Auto Scaling group. If you specify this parameter, Amazon EC2 Auto Scaling passes the operator identity to EC2 for instance launches and only allows the designated operator to make changes to the Auto Scaling group. All mutating API calls from non-operator callers are rejected with an AccessDenied exception.
PlacementGroupstringThe name of an existing placement group into which to launch your instances. To remove the placement group setting, pass an empty string for placement-group. For more information about placement groups, see Placement groups in the Amazon EC2 User Guide. A cluster placement group is a logical grouping of instances within a single Availability Zone. You cannot specify multiple Availability Zones and a cluster placement group.
PreferencesobjectSets your preferences for the instance refresh so that it performs as expected when you start it. Includes the instance warmup time, the minimum and maximum healthy percentages, and the behaviors that you want Amazon EC2 Auto Scaling to use if instances that are in Standby state or protected from scale in are found. You can also choose to enable additional features, such as the following: Auto rollback Checkpoints CloudWatch alarms Skip matching Bake time
RecurrencestringThe recurring schedule for this action. This format consists of five fields separated by white spaces: [Minute] [Hour] [Day_of_Month] [Month_of_Year] [Day_of_Week]. The value must be in quotes (for example, "30 0 1 1,6,12 *"). For more information about this format, see Crontab. When StartTime and EndTime are specified with Recurrence, they form the boundaries of when the recurring action starts and stops. Cron expressions use Universal Coordinated Time (UTC) by default.
RetryStrategystringSpecifies whether to retry asynchronously if the synchronous launch fails. Valid values are NONE (default, no async retry) and RETRY_WITH_GROUP_CONFIGURATION (increase desired capacity and retry with group configuration).
ScalingProcessesarrayOne or more of the following processes: Launch Terminate AddToLoadBalancer AlarmNotification AZRebalance HealthCheck InstanceRefresh ReplaceUnhealthy ScheduledActions If you omit this property, all processes are specified.
ServiceLinkedRoleARNstringThe Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling group uses to call other Amazon Web Services on your behalf. For more information, see Service-linked roles in the Amazon EC2 Auto Scaling User Guide.
SkipZonalShiftValidationbooleanIf you enable zonal shift with cross-zone disabled load balancers, capacity could become imbalanced across Availability Zones. To skip the validation, specify true. For more information, see Auto Scaling group zonal shift in the Amazon EC2 Auto Scaling User Guide.
StartTimestring (date-time)The date and time for this action to start, in YYYY-MM-DDThh:mm:ssZ format in UTC/GMT only and in quotes (for example, "2021-06-01T00:00:00Z"). If you specify Recurrence and StartTime, Amazon EC2 Auto Scaling performs the action at this time, and then performs the action based on the specified recurrence.
StrategystringThe strategy to use for the instance refresh. The default value is Rolling.
SubnetIdsarrayThe subnet IDs for the instance launch. Either AvailabilityZones or SubnetIds must be specified. If both are specified, the subnets must reside in the specified Availability Zones.
TagsarrayOne or more tags. You can tag your Auto Scaling group and propagate the tags to the Amazon EC2 instances it launches. Tags are not propagated to Amazon EBS volumes. To add tags to Amazon EBS volumes, specify the tags in a launch template but use caution. If the launch template specifies an instance tag with a key that is also specified for the Auto Scaling group, Amazon EC2 Auto Scaling overrides the value of that instance tag with the value specified by the Auto Scaling group. For more information, see Tag Auto Scaling groups and instances in the Amazon EC2 Auto Scaling User Guide.
TargetGroupARNsarrayThe Amazon Resource Names (ARN) of the Elastic Load Balancing target groups to associate with the Auto Scaling group. Instances are registered as targets with the target groups. The target groups receive incoming traffic and route requests to one or more registered targets. For more information, see Use Elastic Load Balancing to distribute traffic across the instances in your Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.
TerminationPoliciesarrayA policy or a list of policies that are used to select the instances to terminate. The policies are executed in the order that you list them. For more information, see Configure termination policies for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide. Valid values: Default | AllocationStrategy | ClosestToNextInstanceHour | NewestInstance | OldestInstance | OldestLaunchConfiguration | OldestLaunchTemplate | arn:aws:lambda:region:account-id:function:my-function:my-alias
Timestring (date-time)This property is no longer used.
TimeZonestringSpecifies the time zone for a cron expression. If a time zone is not provided, UTC is used by default. Valid values are the canonical names of the IANA time zones, derived from the IANA Time Zone Database (such as Etc/GMT+9 or Pacific/Tahiti). For more information, see https:​//en.wikipedia.org/wiki/List_of_tz_database_time_zones.
TrafficSourcesarrayThe list of traffic sources to attach to this Auto Scaling group. You can use any of the following as traffic sources for an Auto Scaling group: Classic Load Balancer, Application Load Balancer, Gateway Load Balancer, Network Load Balancer, and VPC Lattice.
VPCZoneIdentifierstringA comma-separated list of subnet IDs for a virtual private cloud (VPC). If you specify VPCZoneIdentifier with AvailabilityZones, the subnets that you specify must reside in those Availability Zones.
WaitForTransitioningInstancesbooleanWhen cancelling an instance refresh, this indicates whether to wait for in-flight launches and terminations to complete. The default is true. When set to false, Amazon EC2 Auto Scaling cancels the instance refresh without waiting for any pending launches or terminations to complete.

SELECT examples

Gets information about the Auto Scaling groups in the account and Region. If you specify Auto Scaling group names, the output includes information for only the specified Auto Scaling groups. If you specify filters, the output includes information for only those Auto Scaling groups that meet the filter criteria. If you do not specify group names or filters, the output includes information for all Auto Scaling groups. This operation also returns information about instances in Auto Scaling groups. To retrieve information about the instances in a warm pool, you must call the DescribeWarmPool API.

SELECT
auto_scaling_group_arn,
auto_scaling_group_name,
availability_zone_distribution,
availability_zone_ids,
availability_zone_impairment_policy,
availability_zones,
capacity_rebalance,
capacity_reservation_specification,
context,
created_time,
default_cooldown,
default_instance_warmup,
deletion_protection,
desired_capacity,
desired_capacity_type,
enabled_metrics,
health_check_grace_period,
health_check_type,
instance_lifecycle_policy,
instance_maintenance_policy,
instances,
launch_configuration_name,
launch_template,
load_balancer_names,
max_instance_lifetime,
max_size,
min_size,
mixed_instances_policy,
new_instances_protected_from_scale_in,
operator,
placement_group,
predicted_capacity,
service_linked_role_arn,
status,
suspended_processes,
tags,
target_group_arns,
termination_policies,
traffic_sources,
vpc_zone_identifier,
warm_pool_configuration,
warm_pool_size
FROM aws.autoscaling.auto_scaling_groups
WHERE region = '{{ region }}' -- required
AND AutoScalingGroupNames = '{{ AutoScalingGroupNames }}'
AND IncludeInstances = '{{ IncludeInstances }}'
AND NextToken = '{{ NextToken }}'
AND MaxRecords = '{{ MaxRecords }}'
AND Filters = '{{ Filters }}'
;

INSERT examples

We strongly recommend using a launch template when calling this operation to ensure full functionality for Amazon EC2 Auto Scaling and Amazon EC2. Creates an Auto Scaling group with the specified name and attributes. If you exceed your maximum limit of Auto Scaling groups, the call fails. To query this limit, call the DescribeAccountLimits API. For information about updating this limit, see Quotas for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide. If you're new to Amazon EC2 Auto Scaling, see the introductory tutorials in Get started with Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide. Every Auto Scaling group has three size properties (DesiredCapacity, MaxSize, and MinSize). Usually, you set these sizes based on a specific number of instances. However, if you configure a mixed instances policy that defines weights for the instance types, you must specify these sizes with the same units that you use for weighting instances.

INSERT INTO aws.autoscaling.auto_scaling_groups (
AutoScalingGroupName,
MinSize,
MaxSize,
region,
LaunchConfigurationName,
LaunchTemplate,
MixedInstancesPolicy,
InstanceId,
DesiredCapacity,
DefaultCooldown,
AvailabilityZones,
AvailabilityZoneIds,
LoadBalancerNames,
TargetGroupARNs,
HealthCheckType,
HealthCheckGracePeriod,
PlacementGroup,
VPCZoneIdentifier,
TerminationPolicies,
NewInstancesProtectedFromScaleIn,
CapacityRebalance,
LifecycleHookSpecificationList,
DeletionProtection,
Tags,
ServiceLinkedRoleARN,
MaxInstanceLifetime,
Context,
DesiredCapacityType,
DefaultInstanceWarmup,
TrafficSources,
InstanceMaintenancePolicy,
AvailabilityZoneDistribution,
AvailabilityZoneImpairmentPolicy,
SkipZonalShiftValidation,
CapacityReservationSpecification,
InstanceLifecyclePolicy,
Operator
)
SELECT
'{{ AutoScalingGroupName }}',
'{{ MinSize }}',
'{{ MaxSize }}',
'{{ region }}',
'{{ LaunchConfigurationName }}',
'{{ LaunchTemplate }}',
'{{ MixedInstancesPolicy }}',
'{{ InstanceId }}',
'{{ DesiredCapacity }}',
'{{ DefaultCooldown }}',
'{{ AvailabilityZones }}',
'{{ AvailabilityZoneIds }}',
'{{ LoadBalancerNames }}',
'{{ TargetGroupARNs }}',
'{{ HealthCheckType }}',
'{{ HealthCheckGracePeriod }}',
'{{ PlacementGroup }}',
'{{ VPCZoneIdentifier }}',
'{{ TerminationPolicies }}',
'{{ NewInstancesProtectedFromScaleIn }}',
'{{ CapacityRebalance }}',
'{{ LifecycleHookSpecificationList }}',
'{{ DeletionProtection }}',
'{{ Tags }}',
'{{ ServiceLinkedRoleARN }}',
'{{ MaxInstanceLifetime }}',
'{{ Context }}',
'{{ DesiredCapacityType }}',
'{{ DefaultInstanceWarmup }}',
'{{ TrafficSources }}',
'{{ InstanceMaintenancePolicy }}',
'{{ AvailabilityZoneDistribution }}',
'{{ AvailabilityZoneImpairmentPolicy }}',
'{{ SkipZonalShiftValidation }}',
'{{ CapacityReservationSpecification }}',
'{{ InstanceLifecyclePolicy }}',
'{{ Operator }}'
;

UPDATE examples

Updates the instance protection settings of the specified instances. This operation cannot be called on instances in a warm pool. For more information, see Use instance scale-in protection in the Amazon EC2 Auto Scaling User Guide. If you exceed your maximum limit of instance IDs, which is 50 per Auto Scaling group, the call fails.

UPDATE aws.autoscaling.auto_scaling_groups
SET
-- No updatable properties
WHERE
InstanceIds = '{{ InstanceIds }}' --required
AND AutoScalingGroupName = '{{ AutoScalingGroupName }}' --required
AND ProtectedFromScaleIn = '{{ ProtectedFromScaleIn }}' --required
AND region = '{{ region }}' --required;

REPLACE examples

Creates or updates a scheduled scaling action for an Auto Scaling group. For more information, see Scheduled scaling in the Amazon EC2 Auto Scaling User Guide. You can view the scheduled actions for an Auto Scaling group using the DescribeScheduledActions API call. If you are no longer using a scheduled action, you can delete it by calling the DeleteScheduledAction API. If you try to schedule your action in the past, Amazon EC2 Auto Scaling returns an error message.

REPLACE aws.autoscaling.auto_scaling_groups
SET
-- No updatable properties
WHERE
AutoScalingGroupName = '{{ AutoScalingGroupName }}' --required
AND ScheduledActionName = '{{ ScheduledActionName }}' --required
AND region = '{{ region }}' --required
AND Time = '{{ Time}}'
AND StartTime = '{{ StartTime}}'
AND EndTime = '{{ EndTime}}'
AND Recurrence = '{{ Recurrence}}'
AND MinSize = '{{ MinSize}}'
AND MaxSize = '{{ MaxSize}}'
AND DesiredCapacity = '{{ DesiredCapacity}}'
AND TimeZone = '{{ TimeZone}}';

DELETE examples

Deletes the specified Auto Scaling group. If the group has instances or scaling activities in progress, you must specify the option to force the deletion in order for it to succeed. The force delete operation will also terminate the EC2 instances. If the group has a warm pool, the force delete option also deletes the warm pool. To remove instances from the Auto Scaling group before deleting it, call the DetachInstances API with the list of instances and the option to decrement the desired capacity. This ensures that Amazon EC2 Auto Scaling does not launch replacement instances. To terminate all instances before deleting the Auto Scaling group, call the UpdateAutoScalingGroup API and set the minimum size and desired capacity of the Auto Scaling group to zero. If the group has scaling policies, deleting the group deletes the policies, the underlying alarm actions, and any alarm that no longer has an associated action. For more information, see Delete your Auto Scaling infrastructure in the Amazon EC2 Auto Scaling User Guide.

DELETE FROM aws.autoscaling.auto_scaling_groups
WHERE AutoScalingGroupName = '{{ AutoScalingGroupName }}' --required
AND region = '{{ region }}' --required
AND ForceDelete = '{{ ForceDelete }}'
;

Lifecycle Methods

Attaches one or more EC2 instances to the specified Auto Scaling group. When you attach instances, Amazon EC2 Auto Scaling increases the desired capacity of the group by the number of instances being attached. If the number of instances being attached plus the desired capacity of the group exceeds the maximum size of the group, the operation fails. If there is a Classic Load Balancer attached to your Auto Scaling group, the instances are also registered with the load balancer. If there are target groups attached to your Auto Scaling group, the instances are also registered with the target groups. For more information, see Detach or attach instances in the Amazon EC2 Auto Scaling User Guide.

EXEC aws.autoscaling.auto_scaling_groups.attach_instances
@AutoScalingGroupName='{{ AutoScalingGroupName }}' --required,
@region='{{ region }}' --required,
@InstanceIds='{{ InstanceIds }}'
;