Skip to content

create_association_batch async

create_association_batch(
    entries: CreateAssociationBatchRequestEntries,
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
    association_dispatch_assume_role: Optional[AssociationDispatchAssumeRoleArn] = None,
) -> CreateAssociationBatchResult

Associates the specified Amazon Web Services Systems Manager document (SSM document) with the specified managed nodes or targets.

When you associate a document with one or more managed nodes using IDs or tags, Amazon Web Services Systems Manager Agent (SSM Agent) running on the managed node processes the document and configures the node as specified.

If you associate a document with a managed node that already has an associated document, the system returns the AssociationAlreadyExists exception.

Parameters:

  • entries (CreateAssociationBatchRequestEntries) –

    One or more associations.

  • association_dispatch_assume_role (Optional[AssociationDispatchAssumeRoleArn], default: None ) –

    A role used by association to take actions on your behalf. State Manager will assume this role and call required APIs when dispatching configurations to nodes. If not specified, service-linked role for Systems Manager will be used by default.

    It is recommended that you define a custom IAM role so that you have full control of the permissions that State Manager has when taking actions on your behalf.

    Service-linked role support in State Manager is being phased out. Associations relying on service-linked role may require updates in the future to continue functioning properly.

Raises:

  • AssociationLimitExceeded –

    You can have at most 2,000 active associations.

  • DuplicateInstanceId –

    You can't specify a managed node ID in more than one association.

  • InternalServerError –

    An error occurred on the server side.

  • InvalidDocument –

    The specified SSM document doesn't exist.

  • InvalidDocumentVersion –

    The document version isn't valid or doesn't exist.

  • InvalidInstanceId –

    The following problems can cause this exception:

    • You don't have permission to access the managed node.

    • Amazon Web Services Systems Manager Agent (SSM Agent) isn't running. Verify that SSM Agent is running.

    • SSM Agent isn't registered with the SSM endpoint. Try reinstalling SSM Agent.

    • The managed node isn't in a valid state. Valid states are: Running, Pending, Stopped, and Stopping. Invalid states are: Shutting-down and Terminated.

  • InvalidOutputLocation –

    The output location isn't valid or doesn't exist.

  • InvalidParameters –

    You must specify values for all required parameters in the Amazon Web Services Systems Manager document (SSM document). You can only supply values to parameters defined in the SSM document.

  • InvalidSchedule –

    The schedule is invalid. Verify your cron or rate expression and try again.

  • InvalidTarget –

    The target isn't valid or doesn't exist. It might not be configured for Systems Manager or you might not have permission to perform the operation.

  • InvalidTargetMaps –

    TargetMap parameter isn't valid.

  • UnsupportedPlatformType –

    The document doesn't support the platform type of the given managed node IDs. For example, you sent an document for a Windows managed node to a Linux node.

  • UnknownServiceError –

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

Source code in docs_src/capo_ssm/_services/async_ssm.py
async def create_association_batch(
    self,
    entries: "capo_ssm.types.create_association_batch_request_entries.CreateAssociationBatchRequestEntries",
    *,
    config_overrides: Optional[AsyncSSMClientConfig] = None,
    association_dispatch_assume_role: Optional[
        "capo_ssm.types.association_dispatch_assume_role_arn.AssociationDispatchAssumeRoleArn"
    ] = None,
) -> "capo_ssm.types.create_association_batch_result.CreateAssociationBatchResult":
    """<p>Associates the specified Amazon Web Services Systems Manager document (SSM document) with the specified managed nodes or targets.</p> <p>When you associate a document with one or more managed nodes using IDs or tags, Amazon Web Services Systems Manager Agent (SSM Agent) running on the managed node processes the document and configures the node as specified.</p> <p>If you associate a document with a managed node that already has an associated document, the system returns the AssociationAlreadyExists exception.</p>

    Args:
        entries: <p>One or more associations.</p>
        association_dispatch_assume_role: <p>A role used by association to take actions on your behalf. State Manager will assume this role and call required APIs when dispatching configurations to nodes. If not specified, <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/using-service-linked-roles.html"> service-linked role for Systems Manager</a> will be used by default. </p> <note> <p>It is recommended that you define a custom IAM role so that you have full control of the permissions that State Manager has when taking actions on your behalf.</p> <p>Service-linked role support in State Manager is being phased out. Associations relying on service-linked role may require updates in the future to continue functioning properly.</p> </note>

    Raises:
        capo_ssm.errors.association_limit_exceeded.AssociationLimitExceeded: <p>You can have at most 2,000 active associations.</p>
        capo_ssm.errors.duplicate_instance_id.DuplicateInstanceId: <p>You can't specify a managed node ID in more than one association.</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_version.InvalidDocumentVersion: <p>The document version isn't valid or doesn't exist.</p>
        capo_ssm.errors.invalid_instance_id.InvalidInstanceId: <p>The following problems can cause this exception:</p> <ul> <li> <p>You don't have permission to access the managed node.</p> </li> <li> <p>Amazon Web Services Systems Manager Agent (SSM Agent) isn't running. Verify that SSM Agent is running.</p> </li> <li> <p>SSM Agent isn't registered with the SSM endpoint. Try reinstalling SSM Agent.</p> </li> <li> <p>The managed node isn't in a valid state. Valid states are: <code>Running</code>, <code>Pending</code>, <code>Stopped</code>, and <code>Stopping</code>. Invalid states are: <code>Shutting-down</code> and <code>Terminated</code>.</p> </li> </ul>
        capo_ssm.errors.invalid_output_location.InvalidOutputLocation: <p>The output location isn't valid or doesn't exist.</p>
        capo_ssm.errors.invalid_parameters.InvalidParameters: <p>You must specify values for all required parameters in the Amazon Web Services Systems Manager document (SSM document). You can only supply values to parameters defined in the SSM document.</p>
        capo_ssm.errors.invalid_schedule.InvalidSchedule: <p>The schedule is invalid. Verify your cron or rate expression and try again.</p>
        capo_ssm.errors.invalid_target.InvalidTarget: <p>The target isn't valid or doesn't exist. It might not be configured for Systems Manager or you might not have permission to perform the operation.</p>
        capo_ssm.errors.invalid_target_maps.InvalidTargetMaps: <p>TargetMap parameter isn't valid.</p>
        capo_ssm.errors.unsupported_platform_type.UnsupportedPlatformType: <p>The document doesn't support the platform type of the given managed node IDs. For example, you sent an document for a Windows managed node to a Linux node.</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_association_batch_request.CreateAssociationBatchRequest]",
    ) -> AsyncOperationResponse[
        "capo_ssm.types.create_association_batch_result.CreateAssociationBatchResult"
    ]:
        import capo_ssm._operations.amazon_ssm.create_association_batch

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

    def _redact_input(
        input_: "capo_ssm.types.create_association_batch_request.CreateAssociationBatchRequest",
    ) -> dict[str, Any]:
        import capo_ssm.types.create_association_batch_request

        return capo_ssm.types.create_association_batch_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_ssm.types.create_association_batch_result.CreateAssociationBatchResult",
    ) -> dict[str, Any]:
        import capo_ssm.types.create_association_batch_result

        return capo_ssm.types.create_association_batch_result.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateAssociationBatch",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_ssm.types.create_association_batch_request.CreateAssociationBatchRequest = {
        "entries": entries
    }
    if association_dispatch_assume_role is not None:
        input_["association_dispatch_assume_role"] = (
            association_dispatch_assume_role
        )

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