Bedrock knowledge base - automate datasource synchronize

0

I want to synchronize data sources in Bedrock knowledge base at midnight every day. Is it possible to automate with code that is not done by humans? If possible, please let me know how

Every day, pdf is being added to S3, and I have to synchronize with that directory including the added pdf.

2 Answers
0

Hello.

You can synchronize to a data source in code using the start_ingestion_job() API.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-agent/client/start_ingestion_job.html
https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-ds-manage.html#kb-ds-update

For example, I think you can synchronize by creating the following code in Lambda.

import boto3

client = boto3.client('bedrock-agent')
def lambda_handler(event, context):
    response = client.start_ingestion_job(
        knowledgeBaseId='knowledgeBaseId',
        dataSourceId='dataSourceId'
    )
profile picture
EXPERT
answered 22 days ago
profile pictureAWS
EXPERT
reviewed 21 days ago
0

Hi,

You have then multiple ways to trigger the codef proposed by Riku as a Lambda function at midnight every day: for example, Eventbridge Scheduler at https://aws.amazon.com/eventbridge/scheduler/

This function will start the job but not monitor it.

If you want to monitor job execution (and retry it when needed), you may prefer AWS Batch scheduling where jobs can last more than the max 15 min of a Lambda. See https://docs.aws.amazon.com/batch/latest/userguide/job_scheduling.html

Best,

Didier

profile pictureAWS
EXPERT
answered 21 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions