Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
• Amazon Systems Manager Change Manager is no longer open to new customers. Existing customers can continue to use the service as normal. For more information, see
Amazon Systems Manager Change Manager availability change.
• The Amazon Systems Manager CloudWatch Dashboard will no longer be available after April 30, 2026. Customers can continue to use Amazon CloudWatch console to view, create, and manage their Amazon CloudWatch dashboards, just as they do today. For more information, see
Amazon CloudWatch Dashboard documentation.
Use DeleteMaintenanceWindow with an Amazon SDK or CLI
The following code examples show how to use DeleteMaintenanceWindow.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- CLI
-
- Amazon CLI
-
To delete a maintenance window
This delete-maintenance-window example removes the specified maintenance window.
aws ssm delete-maintenance-window \
--window-id "mw-1a2b3c4d5e6f7g8h9"
Output:
{
"WindowId":"mw-1a2b3c4d5e6f7g8h9"
}
For more information, see Delete a Maintenance Window (Amazon CLI) in the Amazon Systems Manager User Guide.
- Java
-
- SDK for Java 2.x
-
/**
* Deletes an AWS SSM Maintenance Window asynchronously.
*
* @param winId The ID of the Maintenance Window to delete.
* <p>
* This method initiates an asynchronous request to delete an SSM Maintenance Window.
* If an exception occurs, it handles the error appropriately.
*/
public void deleteMaintenanceWindow(String winId) {
DeleteMaintenanceWindowRequest windowRequest = DeleteMaintenanceWindowRequest.builder()
.windowId(winId)
.build();
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
getAsyncClient().deleteMaintenanceWindow(windowRequest)
.thenAccept(response -> {
System.out.println("The maintenance window was successfully deleted.");
})
.exceptionally(ex -> {
throw new CompletionException(ex);
}).join();
}).exceptionally(ex -> {
Throwable cause = (ex instanceof CompletionException) ? ex.getCause() : ex;
if (cause instanceof SsmException) {
throw new RuntimeException("SSM error: " + cause.getMessage(), cause);
} else {
throw new RuntimeException("Unexpected error: " + cause.getMessage(), cause);
}
});
try {
future.join();
} catch (CompletionException ex) {
throw ex.getCause() instanceof RuntimeException ? (RuntimeException) ex.getCause() : ex;
}
}
- JavaScript
-
- SDK for JavaScript (v3)
-
import { DeleteMaintenanceWindowCommand, SSMClient } from "@aws-sdk/client-ssm";
import { parseArgs } from "node:util";
/**
* Delete an SSM maintenance window.
* @param {{ windowId: string }}
*/
export const main = async ({ windowId }) => {
const client = new SSMClient({});
try {
await client.send(
new DeleteMaintenanceWindowCommand({ WindowId: windowId }),
);
console.log(`Maintenance window '${windowId}' deleted.`);
return { Deleted: true };
} catch (caught) {
if (caught instanceof Error && caught.name === "MissingParameter") {
console.warn(`${caught.message}. Did you provide this value?`);
} else {
throw caught;
}
}
};
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example removes a maintenance window.
Remove-SSMMaintenanceWindow -WindowId "mw-06d59c1a07c022145"
Output:
mw-06d59c1a07c022145
- Tools for PowerShell V5
-
Example 1: This example removes a maintenance window.
Remove-SSMMaintenanceWindow -WindowId "mw-06d59c1a07c022145"
Output:
mw-06d59c1a07c022145
- Python
-
- SDK for Python (Boto3)
-
class MaintenanceWindowWrapper:
"""Encapsulates AWS Systems Manager maintenance window actions."""
def __init__(self, ssm_client):
"""
:param ssm_client: A Boto3 Systems Manager client.
"""
self.ssm_client = ssm_client
self.window_id = None
self.name = None
@classmethod
def from_client(cls):
ssm_client = boto3.client("ssm")
return cls(ssm_client)
def delete(self):
"""
Delete the associated AWS Systems Manager maintenance window.
"""
if self.window_id is None:
return
try:
self.ssm_client.delete_maintenance_window(WindowId=self.window_id)
logger.info("Deleted maintenance window %s.", self.window_id)
print(f"Deleted maintenance window {self.name}")
self.window_id = None
except ClientError as err:
logger.error(
"Couldn't delete maintenance window %s. Here's why: %s: %s",
self.window_id,
err.response["Error"]["Code"],
err.response["Error"]["Message"],
)
raise
- SAP ABAP
-
- SDK for SAP ABAP
-
TRY.
lo_ssm->deletemaintenancewindow( iv_windowid = iv_window_id ).
MESSAGE 'Maintenance window deleted.' TYPE 'I'.
CATCH /aws1/cx_ssminternalservererr.
MESSAGE 'Internal server error occurred.' TYPE 'I'.
ENDTRY.
For a complete list of Amazon SDK developer guides and code examples, see
Using this service with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.