Create EventBridge rules for instance refresh events
The following example creates an EventBridge rule to send an email notification. It does this each time that your Auto Scaling group emits an event when a checkpoint is reached during an instance refresh. The procedure for setting up email notifications using Amazon SNS is included. To use Amazon SNS to send email notifications, you must first create a topic and then subscribe your email addresses to the topic.
For more information about the instance refresh feature, see Use an instance refresh to update instances in an Auto Scaling group.
Create an Amazon SNS topic
An SNS topic is a logical access point, a communication channel that your Auto Scaling group uses to send the notifications. You create a topic by specifying a name for your topic.
Topic names must meet the following requirements:
-
Have 1-256 characters
-
Contain uppercase and lowercase ASCII letters, numbers, underscores, or hyphens
For more information, see Creating an Amazon SNS topic in the Amazon Simple Notification Service Developer Guide.
Subscribe to the Amazon SNS topic
To receive the notifications that your Auto Scaling group sends to the topic, you must subscribe an endpoint to the topic. In this procedure, for Endpoint, specify the email address where you want to receive the notifications from Amazon EC2 Auto Scaling.
For more information, see Subscribing to an Amazon SNS topic in the Amazon Simple Notification Service Developer Guide.
Confirm your Amazon SNS subscription
Amazon SNS sends a confirmation email to the email address you specified in the previous step.
Make sure that you open the email from AWS Notifications and choose the link to confirm the subscription before you continue with the next step.
You will receive an acknowledgment message from AWS. Amazon SNS is now configured to receive notifications and send the notification as an email to the email address that you specified.
Route events to your Amazon SNS topic
Create a rule that matches selected events and routes them to your Amazon SNS topic to notify subscribed email addresses.
To create a rule that sends notifications to your Amazon SNS topic
Open the Amazon EventBridge console at https://console.aws.amazon.com/events/
. -
In the navigation pane, choose Rules.
-
Choose Create rule.
-
For Define rule detail, do the following:
-
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.
-
For Event bus, choose default. When an AWS service in your account generates an event, it always goes to your account's default event bus.
-
For Rule type, choose Rule with an event pattern.
-
Choose Next.
-
-
For Build event pattern, do the following:
-
For Event source, choose AWS events or EventBridge partner events.
-
For Event pattern, do the following:
-
For Event source, choose AWS services.
-
For AWS service, choose Auto Scaling.
-
For Event type, choose Instance Refresh.
-
By default, the rule matches any instance refresh event. To create a rule that notifies you when a checkpoint is reached during an instance refresh, choose Specific instance event(s) and select EC2 Auto Scaling Instance Refresh Checkpoint Reached.
-
By default, the rule matches any Auto Scaling group in the Region. To make the rule match a specific Auto Scaling group, choose Specific group name(s) and select one or more Auto Scaling groups.
-
Choose Next.
-
-
-
For Select target(s), do the following:
-
For Target types, choose AWS service.
-
For Select a target, choose SNS topic.
-
For Topic, choose your Amazon SNS topic.
-
(Optional) Under Additional settings, you can optionally configure additional settings. For more information, see Creating Amazon EventBridge rules that react to events in the Amazon EventBridge User Guide.
-
Choose Next.
-
-
(Optional) For Tags, you can optionally assign one or more tags to your rule, and then choose Next.
-
For Review and create, review the details of the rule and modify them as necessary. Then, choose Create rule.