Skip to content

How do I resolve the "Failed to delete knowledge base" error in Amazon Bedrock?

4 minute read
-2

I tried to delete the Amazon Bedrock knowledge base and received the "Failed to delete knowledge base" error.

Short description

When you create a knowledge base, the default dataDeletionPolicy is set to Delete. If you delete the data source that's associated with the knowledge base, then the policy deletes all the data but doesn't delete the vector store. If you set the dataDeletionPolicy to Retain, then the policy retains all the data if you delete your data source.

When you delete an Amazon Bedrock knowledge base, you might receive the following error:

"Failed to delete example-knowledge-base. Unable to delete data from vector store for data source with example-id. Check your vector store configurations and permissions and retry your request. If the issue persists, consider updating the dataDeletionPolicy of the data source to RETAIN and retry your request."

This error occurs because of the following reasons:

  • The vector store doesn't exist or you previously deleted it.
  • The knowledge base execution role doesn't have AWS Identity and Access Management (IAM) permissions to delete the data that's stored in the vector store.
  • The knowledge base service role doesn't have the required permissions to operate specific database APIs.

To resolve this error, complete one or more of the resolutions.

Resolution

Confirm that the associated vector store exists

Complete the following steps:

  1. Open the Amazon OpenSearch Service console.
  2. In the navigation pane, expand Serverless and choose Collections.
  3. In the search bar, enter the collection associated with the knowledge base. If the collection isn't available, then you already deleted the vector store.

Set the data deletion policy to Retain

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

Complete the following steps:

  1. Open the Amazon Bedrock console.
  2. In the navigation pane, under Build, choose Knowledge Bases.
  3. Find the knowledge base with the Delete unsuccessful status.
  4. Select the data source name for that knowledge base.
  5. Choose Edit.
  6. Expand Advanced settings, set the Data deletion policy to Retain.
  7. Choose Submit.
  8. Delete the data source.
  9. Delete the knowledge base.

You can also run the update-data-source AWS CLI command to change the data source deletion policy:

aws bedrock-agent update-data-source --region region-name --data-source-id your-data-source-id --knowledge-base-id your-knowledge-base-id --name "your-knowledge-base-name" --data-source-configuration '{"s3Configuration":{"bucketArn":"arn:aws:s3:::<S3_Bucket_Name>"},"type":"S3"}' --vector-ingestion-configuration '{"parsingConfiguration":{"bedrockFoundationModelConfiguration":{"modelArn":"arn:aws:bedrock:region: account-id:inference-profile/model_id"},"parsingStrategy":"BEDROCK_FOUNDATION_MODEL"}}' --data-deletion-policy "RETAIN"

Note: Replace the following values:

  • region-name with your AWS Region
  • your-data-source-id with your data source id
  • your-knowledge-base-id with your knowledge base id
  • your-knowledge-base-name with your knowledge base name
  • region with your Region
  • account-id with your AWS account id
  • model_id with your Amazon Bedrock model id

Grant the IAM role permissions to delete data

To resolve your permission issues, take one of the following actions based on the service that you use for the vector store:

  • For Amazon OpenSearch Serverless, update the data access policy with the permissions to delete.

  • For Amazon Aurora PostgreSQL-Compatible Edition, run one of the following SQL commands to grant permission to the primary user:

    GRANT pg_read_all_data, pg_write_all_data TO example-username;

    Note: Replace example-username with the primary username.
    -or-
    Run the following code:

    GRANT SELECT, DELETE ON example-schema-name. example-table-name TO example-username;

    Note: Replace example-schema-name with the schema name, example-table-name with the table name, and example-username with the primary user.

  • For third-party databases, make sure that you have the required permissions for data deletion.

AWS OFFICIALUpdated 3 months ago
5 Comments

This does not work. You said:

  1. Choose Edit. Then, choose Advanced settings.

However, there is no advanced settings option available.

replied a year ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

AWS
EXPERT
replied a year ago

I encountered the same issue and wrote a bug report about it. In the end, switching the AWS Console language to English resolved the problem.

https://repost.aws/ko/questions/QUVFQSxtdyR_e1S68CIJ5bWQ/bug-report-the-issue-of-being-unable-to-delete-bedrock-knowledge-resources-depending-on-the-language

replied a year ago

this article details how to find the advanced settings for the KB's data source. I was able to delete my test KBs.

AWS
replied 10 months ago

This method failed for me. When I select Advanced settings to set the dataDeletionPolicy to "Retain", I get this error: "vectorIngestionConfiguration.parsingConfiguration cannot be updated once created."

So it seems that the knowledgebase source is frozen once created? Meaning I can't delete it once it's been created, and can't fix the settings because it's immutable.

replied 3 months ago