How to create AWS Maintenance Windows with AWS SSM

Do you have any routine housekeeping requirements in your cloud environment? Sure you do. If you are on AWS, AWS Systems Manager Maintenance Windows allows you to automate these tasks and make sure they run on a schedule without manual intervention.

AWS Systems Manager allows you to schedule administrative tasks on managed instances.

Some common use cases include:

  • Running patch updates
  • Cleaning up disk space
  • Restarting services
  • Rotating logs
  • Running custom PowerShell or shell scripts
  • Executing automation workflows

Instead of manually logging into servers, AWS handles the scheduling and execution for you.

Prerequisites

Before creating a maintenance window, make sure:

  • Your EC2 instances are managed by AWS Systems Manager.
  • The SSM Agent is installed and running.
  • The instances have the required IAM permissions.
  • You have permissions to create and manage Maintenance Windows.

Create and Configure the Maintenance Window

Open the AWS Console and navigate to:

AWS Systems Manager → Maintenance Windows

Click Create maintenance window.

Choose a meaningful name that describes the task.

Add a short description explaining the purpose of the maintenance window.

AWS provides several scheduling options:

  • Cron Schedule Builder
  • Rate Schedule Builder
  • Custom Cron Expression

For recurring maintenance tasks, the Cron Schedule Builder is usually the easiest option.

Specify how long AWS should allow the maintenance window to remain active.

Configure how long before the window closes AWS should stop starting new tasks.

This ensures new executions are not started when there is not enough time remaining.

Rate control determines how aggressively AWS executes tasks across your targets.

The concurrency setting controls how many targets can execute the task simultaneously. For example, AWS can run the task against up to 50% of the target instances at the same time.

The error threshold defines how many failures are allowed before AWS stops the task. For critical workloads, setting a low error threshold can help prevent widespread issues.

Choose an appropriate Maintenance Window service role from the dropdown list.

AWS typically creates a role similar to AWSSystemsManagerEC2AccessRole.

Ensure the role has the permissions required for the task you plan to execute.

Review your settings and create the Maintenance Window.

Once created, you will be taken to the Maintenance Window dashboard where you can manage targets, tasks, history, and schedules.

Register a Task

Now that your maintenance window is created, you need to set a task for it to execute.

Open your newly created Maintenance Window and navigate to the Tasks tab.

Click Register Task → Register Run Command Task.

This allows Systems Manager to execute a command document during the scheduled window.

Choose the SSM document that contains the commands you want AWS to execute.

Select the desired document version and configure any required parameters.

Finally, choose the servers that should execute the task.

After registering the task, save the configuration and verify the task appears under the Maintenance Window.

Monitor Execution Results

You can monitor execution results through:

  • Systems Manager Maintenance Window History
  • Run Command History
  • CloudWatch Logs

#aws #cloud

0 Comments