-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Hi there!
Seems there is no way to use an existing OpenSearch collection. At least, no mentions of how to do that properly.
Description
There is no proper way to create a Knowledge Base with an existing OpenSearch Collection.
I've created a standalone OpenSearch collection with a correct name and security policies because collection_name
is completely ignored while creating security policies (create_default_kb
).
Configuration
I have the existing OpenSearch collection that I want to reuse, so I tried this setup:
resource "aws_iam_role" "bedrock_kb_role" {
name = "AWSBedrockKBRole"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = {
Service = "bedrock.amazonaws.com"
}
Action = "sts:AssumeRole"
}
]
})
}
module "knowledge_base" {
source = "aws-ia/bedrock/aws"
version = "0.0.29"
# Knowledge base configuration
kb_type = "VECTOR"
create_kb_log_group = true
create_kb = true
# kb_role_arn = aws_iam_role.bedrock_kb_role.arn
create_opensearch_config = true
kb_storage_type = "OPENSEARCH_SERVERLESS"
use_existing_s3_data_source = true
kb_s3_data_source = module.data_bucket.s3_bucket_arn
collection_arn = module.opensearch_serverless.arn
collection_name = module.opensearch_serverless.name
create_vector_ingestion_configuration = true
number_of_replicas = 1
kb_name = "compatibility_kb"
kb_description = "This knowledge base is designed to help you with compatibility questions."
kb_embedding_model_arn = "arn:aws:bedrock:eu-west-1::foundation-model/amazon.titan-embed-text-v2:0"
kb_log_group_retention_in_days = 90
# Agent configuration
create_agent = true
foundation_model = "anthropic.claude-sonnet-4-20250514-v1:0"
instruction = local.ai_agent_instructions
agent_name = "compatibility-agent"
agent_description = "This agent is designed to help you with compatibility questions."
# idle_session_ttl could be set to 1 hour to keep chat history active
}
Errors
I have different issues depending on whether a Knowledge Base (kb_role_arn
) role is configured or not.
Without existing role (kb_role_arn
is null
), I've got this one:
If you know how to create a Knowledge Base with an existing collection, please let me know 🙏🏻
I believe that it should be easy and unified. Thanks in advance!