- Newest
- Most votes
- Most comments
You can easily monitor EC2 instance state changes using CloudWatch alarms and notifications. Here's the simplest approach:
- Create a CloudWatch alarm that monitors your EC2 instance's state changes
- Configure the alarm to send you notifications through Amazon SNS (Simple Notification Service) when your instance changes state (stops, terminates, etc.)
When an EC2 instance changes state, it sends an "EC2 Instance State-change Notification" event to Amazon EventBridge. These state changes include:
- pending
- running
- stopping
- stopped
- shutting-down
- terminated
You can also set up more proactive monitoring by creating CloudWatch alarms for important metrics like CPUUtilization, DiskReadOps, DiskWriteOps, NetworkIn, or NetworkOut to identify potential issues before they cause instance termination.
For a beginner, the most straightforward approach is to create a CloudWatch alarm that sends an email notification when an instance changes state. This will help you stay informed about any stops, terminations, or other state changes to your EC2 instances.
Sources
State change events for Amazon EC2 instances - Amazon Elastic Compute Cloud
Troubleshoot EC2 instance termination in Amazon ECS | AWS re:Post
Relevant content
- asked 14 days ago
- asked 6 months ago