Skip to content

create_document async

create_document(
    content: DocumentContent,
    name: DocumentName,
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
    requires: Optional[DocumentRequiresList] = None,
    attachments: Optional[AttachmentsSourceList] = None,
    display_name: Optional[DocumentDisplayName] = None,
    version_name: Optional[DocumentVersionName] = None,
    document_type: Optional[DocumentType] = None,
    document_format: Optional[DocumentFormat] = None,
    target_type: Optional[TargetType] = None,
    tags: Optional[TagList] = None,
) -> CreateDocumentResult

Creates a Amazon Web Services Systems Manager (SSM document). An SSM document defines the actions that Systems Manager performs on your managed nodes. For more information about SSM documents, including information about supported schemas, features, and syntax, see Amazon Web Services Systems Manager Documents in the Amazon Web Services Systems Manager User Guide.

Parameters:

  • content (DocumentContent) –

    The content for the new SSM document in JSON or YAML format. The content of the document must not exceed 64KB. This quota also includes the content specified for input parameters at runtime. We recommend storing the contents for your new document in an external JSON or YAML file and referencing the file in a command.

    For examples, see the following topics in the Amazon Web Services Systems Manager User Guide.

  • requires (Optional[DocumentRequiresList], default: None ) –

    A list of SSM documents required by a document. This parameter is used exclusively by AppConfig. When a user creates an AppConfig configuration in an SSM document, the user must also specify a required document for validation purposes. In this case, an ApplicationConfiguration document requires an ApplicationConfigurationSchema document for validation purposes. For more information, see What is AppConfig? in the AppConfig User Guide.

  • attachments (Optional[AttachmentsSourceList], default: None ) –

    A list of key-value pairs that describe attachments to a version of a document.

  • name (DocumentName) –

    A name for the SSM document.

    You can't use the following strings as document name prefixes. These are reserved by Amazon Web Services for use as document name prefixes:

    • aws

    • amazon

    • amzn

    • AWSEC2

    • AWSConfigRemediation

    • AWSSupport

  • display_name (Optional[DocumentDisplayName], default: None ) –

    An optional field where you can specify a friendly name for the SSM document. This value can differ for each version of the document. You can update this value at a later time using the UpdateDocument operation.

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

    An optional field specifying the version of the artifact you are creating with the document. For example, Release12.1. This value is unique across all versions of a document, and can't be changed.

  • document_type (Optional[DocumentType], default: None ) –

    The type of document to create.

    The DeploymentStrategy document type is an internal-use-only document type reserved for AppConfig.

  • document_format (Optional[DocumentFormat], default: None ) –

    Specify the document format for the request. The document format can be JSON, YAML, or TEXT. JSON is the default format.

  • target_type (Optional[TargetType], default: None ) –

    Specify a target type to define the kinds of resources the document can run on. For example, to run a document on EC2 instances, specify the following value: /AWS::EC2::Instance. If you specify a value of '/' the document can run on all types of resources. If you don't specify a value, the document can't run on any resources. For a list of valid resource types, see Amazon Web Services resource and property types reference in the CloudFormation User Guide.

  • tags (Optional[TagList], default: None ) –

    Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment. For example, you might want to tag an SSM document to identify the types of targets or the environment where it will run. In this case, you could specify the following key-value pairs:

    • Key=OS,Value=Windows

    • Key=Environment,Value=Production

    To add tags to an existing SSM document, use the AddTagsToResource operation.

Raises:

Source code in docs_src/capo_ssm/_services/async_ssm.py
async def create_document(
    self,
    content: "capo_ssm.types.document_content.DocumentContent",
    name: "capo_ssm.types.document_name.DocumentName",
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
    requires: Optional[
        "capo_ssm.types.document_requires_list.DocumentRequiresList"
    ] = None,
    attachments: Optional[
        "capo_ssm.types.attachments_source_list.AttachmentsSourceList"
    ] = None,
    display_name: Optional[
        "capo_ssm.types.document_display_name.DocumentDisplayName"
    ] = None,
    version_name: Optional[
        "capo_ssm.types.document_version_name.DocumentVersionName"
    ] = None,
    document_type: Optional["capo_ssm.types.document_type.DocumentType"] = None,
    document_format: Optional[
        "capo_ssm.types.document_format.DocumentFormat"
    ] = None,
    target_type: Optional["capo_ssm.types.target_type.TargetType"] = None,
    tags: Optional["capo_ssm.types.tag_list.TagList"] = None,
) -> "capo_ssm.types.create_document_result.CreateDocumentResult":
    """<p>Creates a Amazon Web Services Systems Manager (SSM document). An SSM document defines the actions that Systems Manager performs on your managed nodes. For more information about SSM documents, including information about supported schemas, features, and syntax, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/documents.html">Amazon Web Services Systems Manager Documents</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p>

    Args:
        content: <p>The content for the new SSM document in JSON or YAML format. The content of the document must not exceed 64KB. This quota also includes the content specified for input parameters at runtime. We recommend storing the contents for your new document in an external JSON or YAML file and referencing the file in a command.</p> <p>For examples, see the following topics in the <i>Amazon Web Services Systems Manager User Guide</i>.</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/documents-using.html#create-ssm-console">Create an SSM document (console)</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/documents-using.html#create-ssm-document-cli">Create an SSM document (command line)</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/documents-using.html#create-ssm-document-api">Create an SSM document (API)</a> </p> </li> </ul>
        requires: <p>A list of SSM documents required by a document. This parameter is used exclusively by AppConfig. When a user creates an AppConfig configuration in an SSM document, the user must also specify a required document for validation purposes. In this case, an <code>ApplicationConfiguration</code> document requires an <code>ApplicationConfigurationSchema</code> document for validation purposes. For more information, see <a href="https://docs.aws.amazon.com/appconfig/latest/userguide/what-is-appconfig.html">What is AppConfig?</a> in the <i>AppConfig User Guide</i>.</p>
        attachments: <p>A list of key-value pairs that describe attachments to a version of a document.</p>
        name: <p>A name for the SSM document.</p> <important> <p>You can't use the following strings as document name prefixes. These are reserved by Amazon Web Services for use as document name prefixes:</p> <ul> <li> <p> <code>aws</code> </p> </li> <li> <p> <code>amazon</code> </p> </li> <li> <p> <code>amzn</code> </p> </li> <li> <p> <code>AWSEC2</code> </p> </li> <li> <p> <code>AWSConfigRemediation</code> </p> </li> <li> <p> <code>AWSSupport</code> </p> </li> </ul> </important>
        display_name: <p>An optional field where you can specify a friendly name for the SSM document. This value can differ for each version of the document. You can update this value at a later time using the <a>UpdateDocument</a> operation.</p>
        version_name: <p>An optional field specifying the version of the artifact you are creating with the document. For example, <code>Release12.1</code>. This value is unique across all versions of a document, and can't be changed.</p>
        document_type: <p>The type of document to create.</p> <note> <p>The <code>DeploymentStrategy</code> document type is an internal-use-only document type reserved for AppConfig.</p> </note>
        document_format: <p>Specify the document format for the request. The document format can be JSON, YAML, or TEXT. JSON is the default format.</p>
        target_type: <p>Specify a target type to define the kinds of resources the document can run on. For example, to run a document on EC2 instances, specify the following value: <code>/AWS::EC2::Instance</code>. If you specify a value of '/' the document can run on all types of resources. If you don't specify a value, the document can't run on any resources. For a list of valid resource types, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html">Amazon Web Services resource and property types reference</a> in the <i>CloudFormation User Guide</i>. </p>
        tags: <p>Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment. For example, you might want to tag an SSM document to identify the types of targets or the environment where it will run. In this case, you could specify the following key-value pairs:</p> <ul> <li> <p> <code>Key=OS,Value=Windows</code> </p> </li> <li> <p> <code>Key=Environment,Value=Production</code> </p> </li> </ul> <note> <p>To add tags to an existing SSM document, use the <a>AddTagsToResource</a> operation.</p> </note>

    Raises:
        capo_ssm.errors.document_already_exists.DocumentAlreadyExists: <p>The specified document already exists.</p>
        capo_ssm.errors.document_limit_exceeded.DocumentLimitExceeded: <p>You can have at most 500 active SSM documents.</p>
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.invalid_document_content.InvalidDocumentContent: <p>The content for the document isn't valid.</p>
        capo_ssm.errors.invalid_document_schema_version.InvalidDocumentSchemaVersion: <p>The version of the document schema isn't supported.</p>
        capo_ssm.errors.max_document_size_exceeded.MaxDocumentSizeExceeded: <p>The size limit of a document is 64 KB.</p>
        capo_ssm.errors.no_longer_supported_exception.NoLongerSupportedException: <p>The requested operation is no longer supported by Systems Manager.</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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ssm.types.create_document_request.CreateDocumentRequest]",
    ) -> AsyncOperationResponse[
        "capo_ssm.types.create_document_result.CreateDocumentResult"
    ]:
        import capo_ssm._operations.amazon_ssm.create_document

        (
            output,
            http_response,
        ) = await capo_ssm._operations.amazon_ssm.create_document.async_create_document(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateDocument")
    )
    input_: capo_ssm.types.create_document_request.CreateDocumentRequest = {
        "content": content,
        "name": name,
    }
    if requires is not None:
        input_["requires"] = requires
    if attachments is not None:
        input_["attachments"] = attachments
    if display_name is not None:
        input_["display_name"] = display_name
    if version_name is not None:
        input_["version_name"] = version_name
    if document_type is not None:
        input_["document_type"] = document_type
    if document_format is not None:
        input_["document_format"] = document_format
    if target_type is not None:
        input_["target_type"] = target_type
    if tags is not None:
        input_["tags"] = tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output