DeleteDocumentCommand

Deletes the Amazon Web Services Systems Manager document (SSM document) and all managed node associations to the document.

Before you delete the document, we recommend that you use DeleteAssociation to disassociate all managed nodes that are associated with the document.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { SSMClient, DeleteDocumentCommand } from "@aws-sdk/client-ssm"; // ES Modules import
// const { SSMClient, DeleteDocumentCommand } = require("@aws-sdk/client-ssm"); // CommonJS import
const client = new SSMClient(config);
const input = { // DeleteDocumentRequest
  Name: "STRING_VALUE", // required
  DocumentVersion: "STRING_VALUE",
  VersionName: "STRING_VALUE",
  Force: true || false,
};
const command = new DeleteDocumentCommand(input);
const response = await client.send(command);
// {};

DeleteDocumentCommand Input

See DeleteDocumentCommandInput for more details

Parameter
Type
Description
Name
Required
string | undefined

The name of the document.

DocumentVersion
string | undefined

The version of the document that you want to delete. If not provided, all versions of the document are deleted.

Force
boolean | undefined

Some SSM document types require that you specify a Force flag before you can delete the document. For example, you must specify a Force flag to delete a document of type ApplicationConfigurationSchema. You can restrict access to the Force flag in an Identity and Access Management (IAM) policy.

VersionName
string | undefined

The version name of the document that you want to delete. If not provided, all versions of the document are deleted.

DeleteDocumentCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.

Throws

Name
Fault
Details
AssociatedInstances
client

You must disassociate a document from all managed nodes before you can delete it.

InternalServerError
server

An error occurred on the server side.

InvalidDocument
client

The specified SSM document doesn't exist.

InvalidDocumentOperation
client

You attempted to delete a document while it is still shared. You must stop sharing the document before you can delete it.

SSMServiceException
Base exception class for all service exceptions from SSM service.