Skip to content

delete_document

delete_document(
    name: DocumentName,
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    document_version: Optional[DocumentVersion] = None,
    version_name: Optional[DocumentVersionName] = None,
    force: Optional[Boolean] = None,
) -> DeleteDocumentResult

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.

Parameters:

  • name (DocumentName) –

    The name of the document.

  • document_version (Optional[DocumentVersion], default: None ) –

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

  • version_name (Optional[DocumentVersionName], default: None ) –

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

  • force (Optional[Boolean], default: None ) –

    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.

Raises:

  • AssociatedInstances –

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

  • InternalServerError –

    An error occurred on the server side.

  • InvalidDocument –

    The specified SSM document doesn't exist.

  • InvalidDocumentOperation –

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

  • TooManyUpdates –

    There are concurrent updates for a resource that supports one update at a time.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_ssm/_services/ssm.py
def delete_document(
    self,
    name: "capo_ssm.types.document_name.DocumentName",
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    document_version: Optional[
        "capo_ssm.types.document_version.DocumentVersion"
    ] = None,
    version_name: Optional[
        "capo_ssm.types.document_version_name.DocumentVersionName"
    ] = None,
    force: Optional["capo_ssm.types.boolean.Boolean"] = None,
) -> "capo_ssm.types.delete_document_result.DeleteDocumentResult":
    """<p>Deletes the Amazon Web Services Systems Manager document (SSM document) and all managed node associations to the document.</p> <p>Before you delete the document, we recommend that you use <a>DeleteAssociation</a> to disassociate all managed nodes that are associated with the document.</p>

    Args:
        name: <p>The name of the document.</p>
        document_version: <p>The version of the document that you want to delete. If not provided, all versions of the document are deleted.</p>
        version_name: <p>The version name of the document that you want to delete. If not provided, all versions of the document are deleted.</p>
        force: <p>Some SSM document types require that you specify a <code>Force</code> flag before you can delete the document. For example, you must specify a <code>Force</code> flag to delete a document of type <code>ApplicationConfigurationSchema</code>. You can restrict access to the <code>Force</code> flag in an Identity and Access Management (IAM) policy.</p>

    Raises:
        capo_ssm.errors.associated_instances.AssociatedInstances: <p>You must disassociate a document from all managed nodes before you can delete it.</p>
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.invalid_document.InvalidDocument: <p>The specified SSM document doesn't exist.</p>
        capo_ssm.errors.invalid_document_operation.InvalidDocumentOperation: <p>You attempted to delete a document while it is still shared. You must stop sharing the document before you can delete it.</p>
        capo_ssm.errors.too_many_updates.TooManyUpdates: <p>There are concurrent updates for a resource that supports one update at a time.</p>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ssm.types.delete_document_request.DeleteDocumentRequest]",
    ) -> OperationResponse[
        "capo_ssm.types.delete_document_result.DeleteDocumentResult"
    ]:
        import capo_ssm._operations.amazon_ssm.delete_document

        output, http_response = (
            capo_ssm._operations.amazon_ssm.delete_document.delete_document(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteDocument")
    )
    input_: capo_ssm.types.delete_document_request.DeleteDocumentRequest = {
        "name": name
    }
    if document_version is not None:
        input_["document_version"] = document_version
    if version_name is not None:
        input_["version_name"] = version_name
    if force is not None:
        input_["force"] = force

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output