Warm pool example events and patterns
Amazon EC2 Auto Scaling supports several predefined patterns in Amazon EventBridge. This simplifies how an event pattern is created. You select field values on a form, and EventBridge generates the pattern for you. At this time, Amazon EC2 Auto Scaling doesn't support predefined patterns for any events that are emitted by an Auto Scaling group with a warm pool. You must enter the pattern as a JSON object. This section and the Create EventBridge rules for warm pool events topic show you how to use an event pattern to select events and send them to targets.
To create EventBridge rules that filter for warm pool-related events that Amazon EC2 Auto Scaling sends to
            EventBridge, include the Origin and Destination fields from the
                detail section of the event. 
The values of Origin and Destination can be the
            following:
EC2 | AutoScalingGroup | WarmPool
Example events
When you add lifecycle hooks to your Auto Scaling group, Amazon EC2 Auto Scaling sends events to EventBridge when an instance transitions into a wait state. For more information, see Use lifecycle hooks with a warm pool in Auto Scaling group.
This section includes examples of these events when your Auto Scaling group has a warm pool. Events are emitted on a best-effort basis.
Note
For events that Amazon EC2 Auto Scaling sends to EventBridge when scaling is successful, see Successful scaling events. For events when scaling is unsuccessful, see Unsuccessful scaling events.
Event examples
Scale-out lifecycle action
Events that are delivered when an instance transitions into a wait state for
                    scale-out events have EC2 Instance-launch Lifecycle Action as the
                    value for detail-type. In the detail object, the
                    values for the Origin and Destination attributes show
                    where the instance is coming from and where it's going.
In this example scale-out event, a new instance launches and its state changes
                    to Warmed:Pending:Wait because it's added to the warm pool. For
                    more information, see Lifecycle state transitions for
                    instances in a warm pool. 
{
  "version": "0",
  "id": "12345678-1234-1234-1234-123456789012",
  "detail-type": "EC2 Instance-launch Lifecycle Action",
  "source": "aws.autoscaling",
  "account": "123456789012",
  "time": "2021-01-13T00:12:37.214Z",
  "region": "us-west-2",
  "resources": [
    "auto-scaling-group-arn"
  ],
  "detail": { 
    "LifecycleActionToken": "71514b9d-6a40-4b26-8523-05e7eEXAMPLE", 
    "AutoScalingGroupName": "my-asg",
    "LifecycleHookName": "my-launch-lifecycle-hook", 
    "EC2InstanceId": "i-1234567890abcdef0", 
    "LifecycleTransition": "autoscaling:EC2_INSTANCE_LAUNCHING",
    "NotificationMetadata": "additional-info",
    "Origin": "EC2",
    "Destination": "WarmPool"
  } 
}
                In this example scale-out event, the state of the instance changes to
                        Pending:Wait because it's added to the Auto Scaling group from the warm
                    pool. For more information, see Lifecycle state transitions for
                    instances in a warm pool. 
{
  "version": "0",
  "id": "12345678-1234-1234-1234-123456789012",
  "detail-type": "EC2 Instance-launch Lifecycle Action",
  "source": "aws.autoscaling",
  "account": "123456789012",
  "time": "2021-01-19T00:35:52.359Z",
  "region": "us-west-2",
  "resources": [
    "auto-scaling-group-arn"
  ],
  "detail": { 
    "LifecycleActionToken": "19cc4d4a-e450-4d1c-b448-0de67EXAMPLE", 
    "AutoScalingGroupName": "my-asg",
    "LifecycleHookName": "my-launch-lifecycle-hook", 
    "EC2InstanceId": "i-1234567890abcdef0", 
    "LifecycleTransition": "autoscaling:EC2_INSTANCE_LAUNCHING",
    "NotificationMetadata": "additional-info",
    "Origin": "WarmPool",
    "Destination": "AutoScalingGroup"
  } 
}
             
            
            
            
            
             
                Scale-in lifecycle action
Events that are delivered when an instance transitions into a wait state for
                    scale-in events have EC2 Instance-terminate Lifecycle Action as the
                    value for detail-type. In the detail object, the
                    values for the Origin and Destination attributes show
                    where the instance is coming from and where it's going.
In this example scale-in event, the state of an instance changes to
                        Warmed:Pending:Wait because it's returned to the warm pool. For
                    more information, see Lifecycle state transitions for
                    instances in a warm pool. 
{
  "version": "0",
  "id": "12345678-1234-1234-1234-123456789012",
  "detail-type": "EC2 Instance-terminate Lifecycle Action",
  "source": "aws.autoscaling",
  "account": "123456789012",
  "time": "2022-03-28T00:12:37.214Z",
  "region": "us-west-2",
  "resources": [
    "auto-scaling-group-arn"
  ],
  "detail": { 
    "LifecycleActionToken": "42694b3d-4b70-6a62-8523-09a1eEXAMPLE", 
    "AutoScalingGroupName": "my-asg", 
    "LifecycleHookName": "my-termination-lifecycle-hook", 
    "EC2InstanceId": "i-1234567890abcdef0", 
    "LifecycleTransition": "autoscaling:EC2_INSTANCE_TERMINATING",
    "NotificationMetadata": "additional-info",
    "Origin": "AutoScalingGroup",
    "Destination": "WarmPool"
  } 
}
             
         
            Example event patterns
The preceding section provides example events emitted by Amazon EC2 Auto Scaling.
EventBridge event patterns have the same structure as the events that they match. The pattern quotes the fields that you want to match and provides the values that you're looking for.
The following fields in the event form the event pattern that is defined in the rule to invoke an action:
"source": "aws.autoscaling"- 
                        
Identifies that the event is from Amazon EC2 Auto Scaling.
 "detail-type": "EC2 Instance-launch Lifecycle Action"- 
                        
Identifies the event type.
 "Origin": "EC2"- 
                        
Identifies where the instance is coming from.
 "Destination": "WarmPool"- 
                        
Identifies where the instance is going to.
 
Use the following sample event pattern to capture all EC2 Instance-launch
                    Lifecycle Action events that are associated with instances entering the
                warm pool.
{ "source": [ "aws.autoscaling" ], "detail-type": [ "EC2 Instance-launch Lifecycle Action" ], "detail": { "Origin": [ "EC2" ], "Destination": [ "WarmPool" ] } }
Use the following sample event pattern to capture all EC2 Instance-launch
                    Lifecycle Action events that are associated with instances leaving the
                warm pool because of a scale-out event.
{ "source": [ "aws.autoscaling" ], "detail-type": [ "EC2 Instance-launch Lifecycle Action" ], "detail": { "Origin": [ "WarmPool" ], "Destination": [ "AutoScalingGroup" ] } }
Use the following sample event pattern to capture all EC2 Instance-launch
                    Lifecycle Action events that are associated with instances launching
                directly into the Auto Scaling group.
{ "source": [ "aws.autoscaling" ], "detail-type": [ "EC2 Instance-launch Lifecycle Action" ], "detail": { "Origin": [ "EC2" ], "Destination": [ "AutoScalingGroup" ] } }
Use the following sample event pattern to capture all EC2 Instance-terminate
                    Lifecycle Action events that are associated with instances returning to
                the warm pool on scale in.
{ "source": [ "aws.autoscaling" ], "detail-type": [ "EC2 Instance-terminate Lifecycle Action" ], "detail": { "Origin": [ "AutoScalingGroup" ], "Destination": [ "WarmPool" ] } }
Use the following sample event pattern to capture all events that are associated
                with EC2 Instance-launch Lifecycle Action, regardless of the origin or
                destination.
{ "source": [ "aws.autoscaling" ], "detail-type": [ "EC2 Instance-launch Lifecycle Action" ] }