View a markdown version of this page

How access controls apply when AWS Context queries data - AWS Context

How access controls apply when AWS Context queries data

AWS Context reads the Agent context as the caller. A trusted identity is the end user’s identity carried in the caller’s session, such as an IAM Identity Center session. A data access role is an optional IAM role that you give a connection in its accessConfig. It is distinct from the connection’s ingestion role.

For AWS sources, each connection reads its source in one of two ways, for every API that reads data:

  • The caller’s credentials (default) – If the connection has no data access role, AWS Context reads the source with the caller’s own credentials, through forward access sessions (FAS).

  • A data access role – If the connection has a data access role, AWS Context assumes it to read the source. It doesn’t fall back to the caller’s credentials.

Either way, the read carries the caller’s trusted identity when the session has one. For Snowflake and Databricks, the source is read as the signed-in user. This has the following consequences:

  • For callers without a trusted identity, such as an application role, the identity that reads the source decides what data comes back. A data access role returns the same data to every such caller, so scope it, for example with Lake Formation data filters.

  • When the request carries a user’s identity and AWS Context can’t pass it to a source, agentic retrieval skips that source and says so in the answer, and an ExecuteSql request against that source fails. If your IAM Identity Center instance uses the legacy experience of trusted identity propagation, a data access role’s trust policy must allow sts:SetContext for the identity to pass. For more information, see How the user’s identity reaches your sources.

The identity that reads a knowledge base connection also reads its documents. Grant that identity, the data access role or the caller, bedrock:Retrieve and bedrock:GetDocumentContent on the knowledge base. AWS Context uses bedrock:GetDocumentContent to check each user’s access to a document’s entities and to read a full document during agentic retrieval. Without it, entities from that knowledge base are left out of results and the request succeeds.

For how source permissions apply to each source type, see Source ACLs. To pass a user’s identity, see Configure trusted identity propagation.

When several connections reach the same data

You can map two or more connections that reach the same data into an Agent context, for example the same knowledge base, the same AWS Glue table, or the same knowledge base document. AWS Context then reads that data through one connection only: of the connections that reach it, the one whose connection mapping you created first. That connection’s setting, the caller’s credentials or its data access role, decides the identity for the whole read. The settings of the other connections don’t apply.

For example, connection A uses the caller’s credentials, connection B uses a data access role, and both reach the same knowledge base. If you created A’s mapping first, AWS Context reads the knowledge base with the caller’s credentials. If you created B’s mapping first, it reads the knowledge base with B’s data access role. Permissions on a knowledge base apply to the whole knowledge base, not to its individual data sources. The identity that AWS Context chooses therefore reads every data source in it.

To control which identity reads shared data, create the mapping of the connection whose setting you want before the mappings of the other connections that reach the same data. A change to the mappings through UpdateAgentContext applies to the queries that follow the update. To keep a source’s reads under one setting, map only connections that use the same setting for it.