AWS Context integration with managed knowledge bases
You can connect a managed Amazon Bedrock knowledge base to AWS Context to bring your unstructured
documents and application content into an Agent Context. AWS Context connects to databases,
documents, and applications and builds an Agent Context: a governed graph of your data,
business definitions, and rules. Agents reach an Agent Context through MCP tools and APIs.
You set up the knowledge base and its data sources in Amazon Bedrock, create a
BEDROCK_KNOWLEDGE_BASE connection to the knowledge base in AWS Context, and
bind the connection into an Agent Context.
After you bind the connection, the knowledge base sends content to AWS Context each time one of its data sources syncs. AWS Context runs ontology-guided extraction over that content and copies each document's access control list (ACL) onto the nodes it builds. At query time, AWS Context reads the knowledge base to return content and to confirm that the end user can still read each document.
If a data source doesn't crawl ACLs, its documents are sent as public, and every caller that can query the Agent Context can receive content extracted from them. Turn on ACLs on each data source where you want per-user results.
Prerequisites
-
An active managed Amazon Bedrock knowledge base in the same AWS Region as the Agent Context.
-
The knowledge base and the Agent Context in the same AWS account, by default. For a knowledge base in another account, see the cross-account step that follows.
-
At least one data source connected to the knowledge base.
-
ACLs turned on for each data source where you want per-user results. For more information, see Access Control Lists awareness enablement.
Connect a managed knowledge base to AWS Context
To connect your managed knowledge base to AWS Context, complete the following steps.
To connect a managed knowledge base to AWS Context
-
Create the knowledge base and connect data sources. Create a managed knowledge base and connect its data sources, turning on ACLs where you want per-user results. For more information, see Create a managed knowledge base and Connect a data source.
Note the knowledge base ARN. The ARN format is:
arn:aws:bedrock:REGION:ACCOUNT_ID:knowledge-base/KB_IDYou can find the ARN in the Amazon Bedrock console on the knowledge base details page, or by calling the
GetKnowledgeBaseAPI. -
Create the ingestion role. In the Agent Context account, create an ingestion role that Amazon Bedrock assumes to send the knowledge base's content to AWS Context. Grant the role
context:IngestAgentContext, limited to this knowledge base with thecontext:SourceArncondition, andbedrock:SendKnowledgeBaseEntitieson the knowledge base. -
Set up query access. Choose how AWS Context reads the knowledge base at query time:
-
The caller's credentials (default). AWS Context reads the knowledge base with the credentials of the principal that calls the Agent Context, through forward access sessions. Attach read permissions to the callers' roles.
-
A data access role that AWS Context assumes, with a trust principal of
context.amazonaws.com. The role's permissions decide what every caller can read.
Read permissions are
bedrock:Retrieve,bedrock:GetDocumentContent, andbedrock:GetKnowledgeBase. The principal that creates the connection needsiam:PassRolefor the ingestion role and for the data access role, if you use one. -
-
(Optional) Grant cross-account access. Skip this step if the knowledge base and the Agent Context are in the same AWS account. For a knowledge base in another account, the knowledge base owner adds statements to the knowledge base's resource policy. These statements grant access to the ingestion role and to the identity that reads the knowledge base, both in the Agent Context account. Only managed knowledge bases support resource policies, and the knowledge base and Agent Context must be in the same AWS Region. For more information, see Resource policies for managed knowledge bases.
-
Create the connection and bind it. In AWS Context, call the
CreateConnectionoperation withdataSource.typeset toBEDROCK_KNOWLEDGE_BASE,dataSource.location.arnset to the knowledge base ARN, the ingestion role iningestionConfig, and the data access role, if used, inaccessConfig. If the knowledge base is encrypted with a customer managed AWS KMS key, addCUSTOMER_MANAGED_KEYtoacknowledgements; otherwiseCreateConnectionreturns aValidationException. Then bind theACTIVEconnection into the Agent Context through a data mapping (connectionMappings). -
Sync the data sources. AWS Context doesn't schedule syncs. Control the timing with the data source sync schedule or a manual sync. Content flows to AWS Context on each sync. For more information, see Sync a data source.
Per-user results at query time
When the request carries the end user's identity, AWS Context propagates it to the knowledge base, which returns only documents that user can read. The knowledge base matches users by email address, with no alias resolution. For more information, see Use IAM Identity Center identities for ACL-aware retrieval.
Related documentation
For detailed setup instructions, permissions policies, query access options, and troubleshooting, see Connect a managed knowledge base to AWS Context in the AWS Context User Guide.