Skip to content

create_ingestion_stream

create_ingestion_stream(
    collection_id: CollectionId,
    ingestion_stream_name: IngestionStreamName,
    index_name: IngestionIndexName,
    source: IngestionStreamSource,
    role_arn: RoleArn,
    *,
    config_overrides: Optional[OpenSearchServerlessClientConfig] = None,
    failure_index_name: Optional[IngestionIndexName] = None,
    tags: Optional[Tags] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateIngestionStreamResponse

Creates an ingestion stream that continuously ingests data from an Amazon S3 bucket into an index in an OpenSearch Serverless collection. An ingestion stream processes Amazon S3 event notifications delivered to an Amazon SQS queue and ingests new objects as they arrive. The stream continues to ingest data until you delete it. To perform a one-time bulk ingestion instead, use CreateIngestionJob.

Parameters:

  • collection_id (CollectionId) –

    The unique identifier of the collection to ingest data into.

  • ingestion_stream_name (IngestionStreamName) –

    The name of the ingestion stream. The name must be unique within the collection.

  • index_name (IngestionIndexName) –

    The name of the index to ingest documents into.

  • failure_index_name (Optional[IngestionIndexName], default: None ) –

    The name of the index where documents that fail to be ingested are recorded.

  • source (IngestionStreamSource) –

    The Amazon S3 source to ingest data from, including the Amazon SQS queue that receives S3 event notifications.

  • role_arn (RoleArn) –

    The Amazon Resource Name (ARN) of the IAM role that OpenSearch Serverless assumes to read data from the source. The role must be in the same account as the collection.

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

    An arbitrary set of tags (key–value pairs) to associate with the ingestion stream.

  • client_token (Optional[ClientToken], default: None ) –

    Unique, case-sensitive identifier to ensure idempotency of the request.

Raises:

  • ConflictException –

    When creating a resource, thrown when a resource with the same name already exists or is being created. When deleting a resource, thrown when the resource is not in the ACTIVE, FAILED, or UPDATE_FAILED state.

  • InternalServerException –

    Thrown when an error internal to the service occurs while processing a request.

  • ResourceNotFoundException –

    Thrown when accessing or deleting a resource that does not exist.

  • ServiceQuotaExceededException –

    Thrown when you attempt to create more resources than the service allows based on service quotas.

  • ValidationException –

    Thrown when the HTTP request contains invalid input or is missing required input.

  • UnknownServiceError –

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

Source code in docs_src/capo_opensearchserverless/_services/open_search_serverless.py
def create_ingestion_stream(
    self,
    collection_id: "capo_opensearchserverless.types.collection_id.CollectionId",
    ingestion_stream_name: "capo_opensearchserverless.types.ingestion_stream_name.IngestionStreamName",
    index_name: "capo_opensearchserverless.types.ingestion_index_name.IngestionIndexName",
    source: "capo_opensearchserverless.types.ingestion_stream_source.IngestionStreamSource",
    role_arn: "capo_opensearchserverless.types.role_arn.RoleArn",
    *,
    config_overrides: Optional[OpenSearchServerlessClientConfig] = None,
    failure_index_name: Optional[
        "capo_opensearchserverless.types.ingestion_index_name.IngestionIndexName"
    ] = None,
    tags: Optional["capo_opensearchserverless.types.tags.Tags"] = None,
    client_token: Optional[
        "capo_opensearchserverless.types.client_token.ClientToken"
    ] = None,
) -> "capo_opensearchserverless.types.create_ingestion_stream_response.CreateIngestionStreamResponse":
    """<p>Creates an ingestion stream that continuously ingests data from an Amazon S3 bucket into an index in an OpenSearch Serverless collection. An ingestion stream processes Amazon S3 event notifications delivered to an Amazon SQS queue and ingests new objects as they arrive. The stream continues to ingest data until you delete it. To perform a one-time bulk ingestion instead, use <code>CreateIngestionJob</code>.</p>

    Args:
        collection_id: <p>The unique identifier of the collection to ingest data into.</p>
        ingestion_stream_name: <p>The name of the ingestion stream. The name must be unique within the collection.</p>
        index_name: <p>The name of the index to ingest documents into.</p>
        failure_index_name: <p>The name of the index where documents that fail to be ingested are recorded.</p>
        source: <p>The Amazon S3 source to ingest data from, including the Amazon SQS queue that receives S3 event notifications.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of the IAM role that OpenSearch Serverless assumes to read data from the source. The role must be in the same account as the collection.</p>
        tags: <p>An arbitrary set of tags (key–value pairs) to associate with the ingestion stream.</p>
        client_token: <p>Unique, case-sensitive identifier to ensure idempotency of the request.</p>

    Raises:
        capo_opensearchserverless.errors.conflict_exception.ConflictException: <p>When creating a resource, thrown when a resource with the same name already exists or is being created. When deleting a resource, thrown when the resource is not in the ACTIVE, FAILED, or UPDATE_FAILED state.</p>
        capo_opensearchserverless.errors.internal_server_exception.InternalServerException: <p>Thrown when an error internal to the service occurs while processing a request.</p>
        capo_opensearchserverless.errors.resource_not_found_exception.ResourceNotFoundException: <p>Thrown when accessing or deleting a resource that does not exist.</p>
        capo_opensearchserverless.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Thrown when you attempt to create more resources than the service allows based on service quotas.</p>
        capo_opensearchserverless.errors.validation_exception.ValidationException: <p>Thrown when the HTTP request contains invalid input or is missing required input.</p>
        capo_opensearchserverless.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_opensearchserverless.types.create_ingestion_stream_request.CreateIngestionStreamRequest]",
    ) -> OperationResponse[
        "capo_opensearchserverless.types.create_ingestion_stream_response.CreateIngestionStreamResponse"
    ]:
        import capo_opensearchserverless._operations.open_search_serverless.create_ingestion_stream

        output, http_response = (
            capo_opensearchserverless._operations.open_search_serverless.create_ingestion_stream.create_ingestion_stream(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateIngestionStream")
    )
    input_: capo_opensearchserverless.types.create_ingestion_stream_request.CreateIngestionStreamRequest = {
        "collection_id": collection_id,
        "ingestion_stream_name": ingestion_stream_name,
        "index_name": index_name,
        "source": source,
        "role_arn": role_arn,
    }
    if failure_index_name is not None:
        input_["failure_index_name"] = failure_index_name
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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