More Info:
There are EC2 instances scheduled for retirement and/or maintenance. Kindly take the necessary steps (reboot, restart or re-launch).Risk Level
LowAddress
SecurityCompliance Standards
CBPRemediation
How to reboot, restart or relaunch and EC2 instance which is scheduled for retirementUsing AWS Console
- Open the AWS Management Console and navigate to the Amazon EC2 service. (In the Cloudanix Console, navigate to “Misconfig” page and look for Affected Assets for “Scheduled Events for EC2 Instances” Policy.)
- From the left navigation pane, click on “Instances” to view the list of EC2 instances.
- Locate the EC2 instance that is scheduled for retirement and select it by clicking on the checkbox next to it.
- From the “Actions” menu above the instance list, select “Instance State” and then click on “Stop”.
- In the confirmation dialog, click on “Stop” to initiate the instance stop process.
- Wait for the instance to stop. You can monitor the status in the “Instance State” column.
- Once the instance has stopped, select the instance again and click on the “Actions” menu.
- From the “Actions” menu, select “Instance State” and then click on “Start”.
- In the confirmation dialog, click on “Start” to initiate the instance start process.
- Wait for the instance to start. You can monitor the status in the “Instance State” column.
- After the instance has started, you can access it using the same methods as before, such as connecting via SSH or accessing any applications running on the instance.
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Here’s how to handle (remediate) AWS EC2 Scheduled Events using the AWS Management Console.
1. Find EC2 instances with scheduled events
- Sign in to the AWS Management Console.
- Go to EC2.
- In the left menu, select Events under Instances (or Scheduled events, depending on console version).
- Or go to Instances, then use the filter:
- Status → Instance status → check With scheduled events.
- Or go to Instances, then use the filter:
2. Understand the event type and choose action
Typical event types and their common remediations:- Instance reboot
- System reboot
- Instance stop (or stop/start)
- Retirement (instance or underlying host)
- Maintenance (e.g., hardware, network, or instance store impact)
3. Remediate by event type (via Console)
A. Instance/System Reboot
If the event is a reboot and your workload tolerates a short interruption:- From EC2 → Instances, select the affected instance.
- Choose Instance state → Reboot instance.
- Confirm the reboot.
- Verify:
- After it comes back, check application health and logs.
- This typically clears the scheduled reboot event.
- Plan a maintenance window before AWS’s scheduled time.
- Then do the manual reboot as above.
B. Instance Stop / Stop-Start
For events specifying the instance must be stopped or stopped/started:- From EC2 → Instances, select the instance.
- Ensure you can tolerate downtime and the root volume is EBS (not instance store).
- Choose Instance state → Stop instance.
- Wait for state to become stopped.
- If event calls for stop/start, then:
- Choose Instance state → Start instance.
- Verify application and that the scheduled event is cleared.
- If your instance uses an ephemeral (instance store) root volume, data is lost on stop. Back up before stopping (AMI, snapshot, data copy).
C. Instance Retirement
If the event says the instance is scheduled for retirement:You must migrate or replace the instance.- Create an AMI (if using EBS root):
- Select the instance → Actions → Image and templates → Create image.
- Name the AMI and create it.
- Launch a new instance from that AMI:
- Go to AMIs, select your new AMI → Launch instance.
- Use a similar instance type, same VPC, subnet, security groups, IAM role, etc.
- Update dependencies:
- Update DNS, load balancer target groups, or other components to point to the new instance.
- Once traffic and data are fully migrated:
- Stop/terminate the old instance (according to your decommissioning policy).
- Change to a different instance type or AZ at this time to avoid similar hardware issues.
D. Scheduled Maintenance That Requires No Action
Sometimes events are informational only (e.g., minor network maintenance) and require no action:- Confirm in the event description that no instance stop/reboot is needed.
- Optionally plan a maintenance window to validate application behavior during/after the window.
4. (Optional) Request reschedule of events
For some events, AWS allows you to request a different time.- In EC2 → Events:
- Select the instance and scheduled event.
- If available, choose Request reschedule or similar option.
- Pick a new time window within the allowed range and submit.
- You must complete the required action (reboot/stop/replace) before the AWS deadline.
5. Verify remediation
After you act:- Go back to EC2 → Events.
- Confirm the event is cleared or marked as completed.
- Validate:
- Instance Status checks are
2/2 checks passed. - Application/services are operational.
- Instance Status checks are
Using CLI
Using CLI
For EC2 “Scheduled Events” there isn’t a single magic “fix” command; remediation is to identify affected instances using the CLI and then take the required action (stop/start, reboot, or replace) before AWS performs the scheduled operation.Below are step‑by‑step AWS CLI instructions.
You’ll see event codes like:
Focus first on events with the nearest
Do the disruptive action yourself at a controlled time instead of waiting for AWS.A. For
B. For
Reboot on your own schedule (often enough):Verify application health afterward.C. For
Sometimes a simple stop/start also clears the event by moving the instance to new hardware:If the event persists, you may have to accept the scheduled maintenance window or migrate workloads to a new instance and decommission the old one.
An empty or missing
If you tell me which event code(s) you’re seeing, I can give a narrower CLI sequence tailored to that exact case.
1. List EC2 instances with scheduled events
instance-stopinstance-rebootsystem-rebootsystem-maintenanceinstance-retirementinstance-retirement-scheduled
InstanceId and event code(s) per instance.2. Prioritize by event time
To sort by the scheduled time:NotBefore time.3. Decide remediation action per event type
General rule:Do the disruptive action yourself at a controlled time instead of waiting for AWS.
A. For instance-stop / instance-retirement
- If the instance is in an Auto Scaling Group (ASG) or behind a load balancer, ensure draining / replacement is handled.
- Stop and start the instance to move it to new hardware:
- If you must preserve the instance exactly but hardware migration isn’t sufficient, create a replacement instance:
Then launch a new instance from that AMI and update DNS/ELB/Target Groups/ASGs as appropriate.
B. For instance-reboot
Reboot on your own schedule (often enough):C. For system-reboot / system-maintenance
Sometimes a simple stop/start also clears the event by moving the instance to new hardware:4. Confirm the event is cleared
After you’ve taken action:Events array indicates the scheduled event is cleared.5. (Optional) Script to remediate all “stop/retirement” events
Example bash snippet to stop/start all affected instances (use carefully):If you tell me which event code(s) you’re seeing, I can give a narrower CLI sequence tailored to that exact case.
Using Python
Using Python
Below is a concise, step‑by‑step approach to detect and remediate EC2 scheduled events (like system reboot/retirement) using Python (boto3).
Remediation usually means:
Look for
1. Understand the “misconfiguration”
For EC2, “Scheduled Events” are AWS‑initiated actions (reboot, stop, retire instances, etc.).Remediation usually means:
- Detecting upcoming scheduled events.
- Taking controlled action yourself before AWS does (e.g., stop/start, replace instance, move workload).
2. Prerequisites
- Install boto3:
- Configure AWS credentials/region (e.g., using
aws configureor environment variables). - IAM role/user must have at least:
ec2:DescribeInstanceStatusec2:StopInstancesec2:StartInstancesec2:RebootInstancesec2:TerminateInstances(only if you choose to terminate/replace)ec2:DescribeInstances
3. Detect scheduled events via Python
Usedescribe_instance_status with IncludeAllInstances=True and look at Events and EventCode.EventCode values such as:instance-rebootsystem-rebootinstance-retirementsystem-maintenanceinstance-stop
4. Decide remediation logic
Typical automated actions:instance-reboot/system-reboot:
→ You may choose to proactively reboot during a maintenance window.instance-stop:
→ Stop/start the instance on your controlled schedule (note: instance-store volumes are lost).instance-retirement:
→ Replace the instance (create a new one from AMI/snapshot, attach EIP, update ASG, etc.).
- Detects events.
- If
instance-stoporinstance-retirementis scheduled, it stops the instance (to force change under your control) and then starts it back.
5. Example remediation script (simple)
6. Hardening as an operational process
- Run this script as a scheduled job (e.g., cron, Lambda with CloudWatch Events).
- Optionally:
- Filter by tags (
DescribeInstances) so you only remediate certain workloads. - Integrate notifications (SNS/Slack) before/after remediation.
- Use different logic per event type (e.g., rebuild instance for
instance-retirement).
- Filter by tags (
instance-retirement, create a new instance from this AMI and move EIP over”), I can give a more specific Python workflow.Using Terraform
Using Terraform
- Use the AWS Console: EC2 → Instances → select instance → “Scheduled events” tab → follow the guidance; for stop/retire events, stop/start or replace the instance (possibly via an Auto Scaling Group or launch template managed in Terraform).
- Or use AWS CLI: for example, stop/start or replace the instance (
aws ec2 stop-instances,start-instances, or create a new instance and update any Terraform-managed references to its ID or to an Auto Scaling Group that replaces it).
terraform plan will show no changes related to scheduled events because they are not part of the Terraform state or schema.
