Create EventBridge rules for warm pool events - Amazon EC2 Auto Scaling
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Create EventBridge rules for warm pool events

The following example creates an EventBridge rule to invoke programmatic actions. It does this each time that your Auto Scaling group emits an event when a new instance is added to the warm pool.

Before you create the rule, create the Amazon Lambda function that you want the rule to use as a target. You must specify this function as the target for the rule. The following procedure provides only the steps for creating the EventBridge rule that acts when new instances enter the warm pool. For an introductory tutorial that shows you how to create a simple Lambda function to invoke when an incoming event matches a rule, see Tutorial: Configure a lifecycle hook that invokes a Lambda function.

For more information about creating and working with warm pools, see Warm pools for Amazon EC2 Auto Scaling.

To create an event rule that invokes a Lambda function

  1. Open the Amazon EventBridge console at

  2. In the navigation pane, choose Rules.

  3. Choose Create rule.

  4. For Define rule detail, do the following:

    1. Enter a Name for the rule, and, optionally, a description.

      A rule can't have the same name as another rule in the same Region and on the same event bus.

    2. For Event bus, choose default. When an Amazon Web Service in your account generates an event, it always goes to your account's default event bus.

    3. For Rule type, choose Rule with an event pattern.

    4. Choose Next.

  5. For Build event pattern, do the following:

    1. For Event source, choose Amazon events or EventBridge partner events.

    2. For Event pattern, choose Custom pattern (JSON editor), and paste the following pattern into the Event pattern box, replacing the text in italics with the name of your Auto Scaling group.

      { "source": [ "aws.autoscaling" ], "detail-type": [ "EC2 Instance-launch Lifecycle Action" ], "detail": { "AutoScalingGroupName": [ "my-asg" ], "Origin": [ "EC2" ], "Destination": [ "WarmPool" ] } }

      To create a rule that matches for other events, modify the event pattern. For more information, see Example event patterns.

    3. Choose Next.

  6. For Select target(s), do the following:

    1. For Target types, choose Amazon Web Service.

    2. For Select a target, choose Lambda function.

    3. For Function, choose the function that you want to send the events to.

    4. (Optional) For Configure version/alias, enter version and alias settings for the target Lambda function.

    5. (Optional) For Additional settings, enter any additional settings as appropriate for your application. For more information, see Creating Amazon EventBridge rules that react to events (step 16) in the Amazon EventBridge User Guide.

    6. Choose Next.

  7. (Optional) For Tags, you can optionally assign one or more tags to your rule, and then choose Next.

  8. For Review and create, review the details of the rule and modify them as necessary. Then, choose Create rule.