bedrock-claude-chat icon indicating copy to clipboard operation
bedrock-claude-chat copied to clipboard

[BUG] OpenSearch Serverless Collection Deployment Failure in Knowledge Base Synchronization

Open caosinf777 opened this issue 7 months ago • 2 comments

🐞 Fix: CloudFormation stack update fails with custom-named OpenSearch Serverless Collection

🐞 Describe the bug

The Knowledge Base synchronization process is failing during CloudFormation stack update with the error: CloudFormation cannot update a stack when a custom-named resource requires replacing. This prevents the successful deployment of our Bedrock Knowledge Base and blocks the synchronization of our documentation.

🔄 To Reproduce

1.- Access the agent management interface 2.- Add a new file to the agent's Knowledge Base 3.- Initiate a synchronization of the Knowledge Base 4.- The synchronization fails with a CloudFormation error

Specifically, the error occurs when:

  • The Knowledge Base already exists with an OpenSearch Serverless collection
  • New content is added that requires updating the vector store configuration
  • The synchronization attempts to update the existing OpenSearch collection instead of creating a new one

📷 Screenshots

N/A

🔎 Logs for Bot Creation/Update Issues

From the EmbeddingStateMachine execution logs:

BrChatKbStack01JFATPNAHEWE7FB6KCE6V2JE6 | 0/29 | 5:05:15 AM | UPDATE_FAILED | AWS::OpenSearchServerless::Collection | KBVectors/VectorCollection (KBVectorsVectorCollection20D923CA) CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename k0vhz3yh13g6q1v0wil6 and update the stack again.

Full error from CodeBuild:

❌ BrChatKbStack01JFATPNAHEWE7FB6KCE6V2JE6 failed: _ToolkitError: The stack named BrChatKbStack01JFATPNAHEWE7FB6KCE6V2JE6 failed to deploy: UPDATE_ROLLBACK_COMPLETE: CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename k0vhz3yh13g6q1v0wil6 and update the stack again.

📝 Additional context

Root Cause Analysis

When adding new content to the Knowledge Base and initiating a synchronization, the CDK deployment process attempts to update the existing OpenSearch Serverless Collection. However, some changes to the collection configuration require a complete replacement rather than an in-place update. CloudFormation has a built-in safety mechanism that prevents replacing custom-named resources during updates to avoid accidental data loss.

The specific trigger appears to be adding new content sources to the Knowledge Base, which modifies the underlying vector store configuration in a way that requires replacement of the OpenSearch collection.

Environment Information

  • AWS Region: us-east-1
  • Resource: OpenSearch Serverless Collection
  • Collection ID: k0vhz3yh13g6q1v0wil6
  • Knowledge Base ID: FTWDOKS4NB
  • Bot ID: 01JFATPNAHEWE7FB6KCE6V2JE6

Proposed Solutions

  1. Rename the Collection in CDK Code: Modify the CDK code to use a new name for the OpenSearch Serverless Collection:

    // In the CDK file where the collection is defined
    new opensearchserverless.CfnCollection(this, 'VectorCollection', {
      name: 'kb-vectors-' + Date.now().toString(), // Use timestamp for uniqueness
      // other properties...
    });
    
  2. Delete and Recreate the Collection: If data preservation is not required:

    aws opensearchserverless delete-collection --id k0vhz3yh13g6q1v0wil6
    

    Then verify deletion is complete and run the CDK deployment again.

  3. Modify Configuration Without Replacement: Review which properties are being changed that require replacement and adjust accordingly.

Implementation Considerations

  • Data in the collection will be lost if deleted
  • OpenSearch may reserve collection names for a period after deletion
  • Any resources referencing this collection will need to be updated

caosinf777 avatar Apr 08 '25 06:04 caosinf777

Reproduction step is not clear. Please describe more the detail. Thank you

statefb avatar Apr 08 '25 06:04 statefb

Reproduction step is not clear. Please describe more the detail. Thank you

updated:

🔄 To Reproduce

1.- Access the agent management interface 2.- Add a new file to the agent's Knowledge Base 3.- Initiate a synchronization of the Knowledge Base 4.- The synchronization fails with a CloudFormation error

Specifically, the error occurs when:

The Knowledge Base already exists with an OpenSearch Serverless collection New content is added that requires updating the vector store configuration The synchronization attempts to update the existing OpenSearch collection instead of creating a new one

caosinf777 avatar Apr 08 '25 06:04 caosinf777

This issue has been labeled as "stale" due to no response by the reporter within 1 month (and 14 days after last commented by someone). And it will be closed automatically 14 days later if not responded.

github-actions[bot] avatar May 09 '25 01:05 github-actions[bot]

This issue has been closed due to no response within 14 days after labeled as "stale", 14 days after last reopened, and 14 days after last commented.

github-actions[bot] avatar May 24 '25 01:05 github-actions[bot]