Skip to content

create_archive async

create_archive(
    archive_name: ArchiveName,
    event_source_arn: EventBusArn,
    *,
    config_overrides: Optional[AsyncEventBridgeClientConfig] = None,
    description: Optional[ArchiveDescription] = None,
    event_pattern: Optional[EventPattern] = None,
    retention_days: Optional[RetentionDays] = None,
    kms_key_identifier: Optional[KmsKeyIdentifier] = None,
) -> CreateArchiveResponse

Creates an archive of events with the specified settings. When you create an archive, incoming events might not immediately start being sent to the archive. Allow a short period of time for changes to take effect. If you do not specify a pattern to filter events sent to the archive, all events are sent to the archive except replayed events. Replayed events are not sent to an archive.

If you have specified that EventBridge use a customer managed key for encrypting the source event bus, we strongly recommend you also specify a customer managed key for any archives for the event bus as well.

For more information, see Encrypting archives in the Amazon EventBridge User Guide.

Parameters:

  • archive_name (ArchiveName) –

    The name for the archive to create.

  • event_source_arn (EventBusArn) –

    The ARN of the event bus that sends events to the archive.

  • description (Optional[ArchiveDescription], default: None ) –

    A description for the archive.

  • event_pattern (Optional[EventPattern], default: None ) –

    An event pattern to use to filter events sent to the archive.

  • retention_days (Optional[RetentionDays], default: None ) –

    The number of days to retain events for. Default value is 0. If set to 0, events are retained indefinitely

  • kms_key_identifier (Optional[KmsKeyIdentifier], default: None ) –

    The identifier of the KMS customer managed key for EventBridge to use, if you choose to use a customer managed key to encrypt this archive. The identifier can be the key Amazon Resource Name (ARN), KeyId, key alias, or key alias ARN.

    If you do not specify a customer managed key identifier, EventBridge uses an Amazon Web Services owned key to encrypt the archive.

    For more information, see Identify and view keys in the Key Management Service Developer Guide.

    If you have specified that EventBridge use a customer managed key for encrypting the source event bus, we strongly recommend you also specify a customer managed key for any archives for the event bus as well.

    For more information, see Encrypting archives in the Amazon EventBridge User Guide.

Raises:

Source code in docs_src/capo_eventbridge/_services/async_event_bridge.py
async def create_archive(
    self,
    archive_name: "capo_eventbridge.types.archive_name.ArchiveName",
    event_source_arn: "capo_eventbridge.types.event_bus_arn.EventBusArn",
    *,
    config_overrides: Optional[AsyncEventBridgeClientConfig] = None,
    description: Optional[
        "capo_eventbridge.types.archive_description.ArchiveDescription"
    ] = None,
    event_pattern: Optional[
        "capo_eventbridge.types.event_pattern.EventPattern"
    ] = None,
    retention_days: Optional[
        "capo_eventbridge.types.retention_days.RetentionDays"
    ] = None,
    kms_key_identifier: Optional[
        "capo_eventbridge.types.kms_key_identifier.KmsKeyIdentifier"
    ] = None,
) -> "capo_eventbridge.types.create_archive_response.CreateArchiveResponse":
    """<p>Creates an archive of events with the specified settings. When you create an archive, incoming events might not immediately start being sent to the archive. Allow a short period of time for changes to take effect. If you do not specify a pattern to filter events sent to the archive, all events are sent to the archive except replayed events. Replayed events are not sent to an archive.</p> <important> <p>If you have specified that EventBridge use a customer managed key for encrypting the source event bus, we strongly recommend you also specify a customer managed key for any archives for the event bus as well. </p> <p>For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/encryption-archives.html">Encrypting archives</a> in the <i>Amazon EventBridge User Guide</i>.</p> </important>

    Args:
        archive_name: <p>The name for the archive to create.</p>
        event_source_arn: <p>The ARN of the event bus that sends events to the archive.</p>
        description: <p>A description for the archive.</p>
        event_pattern: <p>An event pattern to use to filter events sent to the archive.</p>
        retention_days: <p>The number of days to retain events for. Default value is 0. If set to 0, events are retained indefinitely</p>
        kms_key_identifier: <p>The identifier of the KMS customer managed key for EventBridge to use, if you choose to use a customer managed key to encrypt this archive. The identifier can be the key Amazon Resource Name (ARN), KeyId, key alias, or key alias ARN.</p> <p>If you do not specify a customer managed key identifier, EventBridge uses an Amazon Web Services owned key to encrypt the archive.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/viewing-keys.html">Identify and view keys</a> in the <i>Key Management Service Developer Guide</i>. </p> <important> <p>If you have specified that EventBridge use a customer managed key for encrypting the source event bus, we strongly recommend you also specify a customer managed key for any archives for the event bus as well. </p> <p>For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/encryption-archives.html">Encrypting archives</a> in the <i>Amazon EventBridge User Guide</i>.</p> </important>

    Raises:
        capo_eventbridge.errors.concurrent_modification_exception.ConcurrentModificationException: <p>There is concurrent modification on a rule, target, archive, or replay.</p>
        capo_eventbridge.errors.internal_exception.InternalException: <p>This exception occurs due to unexpected causes.</p>
        capo_eventbridge.errors.invalid_event_pattern_exception.InvalidEventPatternException: <p>The event pattern is not valid.</p>
        capo_eventbridge.errors.limit_exceeded_exception.LimitExceededException: <p>The request failed because it attempted to create resource beyond the allowed service quota.</p>
        capo_eventbridge.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The resource you are trying to create already exists.</p>
        capo_eventbridge.errors.resource_not_found_exception.ResourceNotFoundException: <p>An entity that you specified does not exist.</p>
        capo_eventbridge.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_eventbridge.types.create_archive_request.CreateArchiveRequest]",
    ) -> AsyncOperationResponse[
        "capo_eventbridge.types.create_archive_response.CreateArchiveResponse"
    ]:
        import capo_eventbridge._operations.aws_events.create_archive

        (
            output,
            http_response,
        ) = await capo_eventbridge._operations.aws_events.create_archive.async_create_archive(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateArchive")
    )
    input_: capo_eventbridge.types.create_archive_request.CreateArchiveRequest = {
        "archive_name": archive_name,
        "event_source_arn": event_source_arn,
    }
    if description is not None:
        input_["description"] = description
    if event_pattern is not None:
        input_["event_pattern"] = event_pattern
    if retention_days is not None:
        input_["retention_days"] = retention_days
    if kms_key_identifier is not None:
        input_["kms_key_identifier"] = kms_key_identifier

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