How to list all AWS maintenance windows in your account

on
Mar 19, 2022
in

AWS maintenance windows allows AWS to update their systems in a coordinated fashion. However, each service has a different way to schedule and report them, which makes it hard to keep track of them. In this blog I introduce a small utility which reports upcoming AWS maintenance windows and actions.

Sometimes an AWS service needs maintenance: an update on the operating system or the version of the software. Maintenance which requires downtime, happens in user-defined maintenance windows. The maintenance window indicates the weekday and start- and end time in which downtime is acceptable.

As each of the services provide their own way of announcing and scheduling maintenance, it is a bit hard to keep track of them. Ideally we would like to be notified when maintenance is available and when maintenance windows are about to occur.

The service AWS Health provides some insight into scheduled
changes. However the AWS Health API is only available for accounts with a support contract.

AWS maintenance windows

The utility aws-maintenance-windows reports the number of upcoming maintenance actions and active windows
across EC2, RDS, Redshift and Opensearch. Optionally the metrics are sent to DataDog. This allows you to create a notification whenever a maintenance windows is pending.

The metrics send are:

  • aws.pending.maintenance.actions

    number of available maintenance actions

  • aws.pending.maintenance.windows

    number of scheduled maintenance windows

usage

to get an overview of all outstanding maintenance, type:

$ aws-maintenance-windows
INFO: Maintenance window of ec2 instance-id i-22222222222222222: The instance is running on degraded hardware on 2022-03-28 00:00:00+00:00
INFO: Maintenance window of rds dbclusteridentifier db: Upgrade to Aurora PostgreSQL 2.9.2 on 2022-03-16 04:00:00+00:00
INFO: Maintenance action available for opensearch domainid es: A newer release R20211203-P4 is available.
INFO: Maintenance windows of opensearch domainid es-2: An update to release R20211203-P5 has been requested and is pending. Before the update starts, you can cancel it any time on 2022-03-20 00:00:00+00:00

This will show you any maintenance available across EC2, RDS, Redshift and Opensearch.

Install

To install the maintenance window reporter utility, type:

pip install aws-maintenance-window-reporter

Alternatively, you can deploy the maintenance window reporter as an AWS Lambda to collect the metrics:

git clone https://github.com/binxio/aws-maintenance-window-reporter.git
cd aws-maintenance-window-reporter
read -p 'DD API key >' DD_API_KEY
aws cloudformation deploy \h
    --capabilities CAPABILITY_IAM \
    --stack-name aws-maintenance-window-reporter \
    --template-file ./cloudformation/aws-maintenance-window-reporter.yaml \ 
    --parameter-overrides "DataDogAPIKey=$DD_API_KEY"

This will install the maintenance window reporter in your AWS account and run every hour.

Conclusion

In this blog I introduced a small utility which will report upcoming maintenance windows and actions. Currently only four services are supported,
but that is easily extended. Just create an issue, or even better create a MR :-p on our github project.

Photo by Christopher Burns on Unsplash

Mark van Holsteijn is a senior software systems architect, and CTO of binx.io. He is passionate about removing waste in the software delivery process and keeping things clear and simple.
Share this article: Tweet this post / Post on LinkedIn