Tutorial: Log State Changes of Amazon EC2 Instances - Amazon CloudWatch Events

Tutorial: Log State Changes of Amazon EC2 Instances

Note

Amazon EventBridge is the preferred way to manage your events. CloudWatch Events and EventBridge are the same underlying service and API, but EventBridge provides more features. Changes you make in either CloudWatch or EventBridge will appear in each console. For more information, see Amazon EventBridge.

In the example in this tutorial, you create a rule causing state-change notifications in Amazon EC2 to be logged in CloudWatch Logs.

To create a rule to log Amazon EC2 state-change notifications in CloudWatch Logs

  1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.

  2. In the navigation pane, choose Events and then Create rule.

  3. For Event Source, do the following:

    1. Choose Event Pattern.

    2. For Service Name, choose EC2.

    3. For Event Type, choose EC2 Instance State-change Notification.

  4. For Targets, choose Add target. In the list of services, choose CloudWatch log group.

  5. For Log Group, enter a name for the log group to receive the state-change notifications.

  6. Choose Configure details.

  7. For Rule definition, enter a name and description for the rule.

  8. Choose Create rule.