I want to receive notifications from Amazon EventBridge when there's a scheduled event for my Amazon Elastic Compute Cloud (Amazon EC2) instance.
Short description
You can create an EventBridge rule to start on a scheduled event for your EC2 instance. Then, you can configure Amazon Simple Notification Service (Amazon SNS) notifications for events that match your event pattern. You can also configure further processing through AWS Lambda.
Resolution
Important: Before you begin, be sure that you have an SNS topic for notifications. If you don't have one, create a new SNS topic and subscribe to it.
Use the EventBridge console to create an EventBridge rule that initiates on an event:
1. Assign a Name to the rule. (Optional) You can also assign a Description to the rule.
2. For Event bus, select default.
3. For Rule type, choose Rule with an event pattern.
4. Choose Next.
5. For Event Source, choose AWS events or EventBridge partner events.
6. (Optional) For Sample events, choose the type of event.
7. For Creation method, choose Use pattern form.
8. For Event source, choose AWS services.
9. For AWS service, choose Health. This is the name of the AWS service as the event source**.**
10. For Event Type, choose Specific Health events.
11. Choose Specific service(s), and then choose EC2.
12. Choose Specific event type category(s), and then choose scheduledChange.
13. (Optional) To create a more specific rule, choose Specific event type code(s) or Specific resource(s). By adding one of these options to the rule, notifications are sent for specific events or instances.
These settings create the following event pattern:
Note: You can also copy and paste the following code as your rule to create your event pattern. After you choose Create Rule, choose Edit in the Event Pattern preview section. Insert the following code, choose Save, and then create an SNS target:
{
"source": [
"aws.health"
],
"detail-type": [
"AWS Health Event"
],
"detail": {
"service": [
"EC2"
],
"eventTypeCategory": [
"scheduledChange"
]
}
}
14. Select your SNS target:
Choose Add Target.
For the target, choose SNS topic.
For Topic, choose the SNS topic that you want to use for notifications.
The following example is an EventBridge event that's forwarded to the target:
{
"version": "0",
"id": "9a06e7c4-fa42-ad91-6186-19a256fdb733",
"detail-type": "AWS Health Event",
"source": "aws.health",
"account": "123456789101",
"time": "2023-03-03T17:00:00Z",
"region": "us-east-1",
"resources": [
"i-abcdefg"
],
"detail": {
"eventArn": "arn:aws:health:region::event id="" ",
"service": "EC2",
"eventTypeCode": "AWS_EC2_MAINTENANCE_SCHEDULED",
"eventTypeCategory": "scheduledChange",
"startTime": "Fri, 3 Mar 2023 17:00:00 GMT",
"endTime": "Fri, 3 Mar 2023 18:00:00 GMT",
"eventDescription": [
{
"language": "en_US",
"latestDescription": "A description of the event will be provided here"
}
],
"affectedEntities": [
{
"entityValue": "i-abcdefg"
}
]
}
}
If your use case requires delivering specific fields to the target, then attach an input transformer under Configure input. Or, attach a Lambda function as a target to run designated processing.
Related information
AWS Health events (CloudWatch Events)
Monitoring AWS Health events with Amazon EventBridge
How do I set up human-readable EventBridge notifications for API calls using input transformer?