Configure identity mapping per source
For source-native permissions to apply per user, the source has to recognize the identity on whose behalf AWS Context is querying. Establish Identity Propagation (see How the user’s identity reaches your sources) so that the end-user identity reaches the source, and ensure the identity AWS Context presents maps to a principal the source authorizes:
-
For AWS Glue Data Catalog, grant the relevant AWS Lake Formation permissions to the identities (or their mapped principals) that should be able to read each resource.
-
For Snowflake Horizon and Databricks Unity Catalog, map the propagated identity to a principal the catalog recognizes, and set the source-side policies that govern what that principal can read.
Each source compares the user’s identity with its ACLs and grants as an exact string. Use the same identifier in the subject that your identity provider sets in the session, in your knowledge base ACLs, and in your AWS Lake Formation grants. For example, if the subject is alice@example.com, an ACL or grant that names alice doesn’t match, and the user gets no results from that source.
You don’t have to set a data access role for any AWS source type. Without one, AWS Context reads the source with the caller’s own credentials, which carry the user’s identity. If you set a data access role and your IAM Identity Center instance uses the legacy experience of trusted identity propagation, add sts:SetContext to the role’s trust policy. AWS Context then can attach the user’s identity when it assumes the role. If the request carries the user’s identity and AWS Context can’t attach it, AWS Context doesn’t read the source. ExecuteSql fails with AccessDeniedException, and AgenticRetrieve answers from the other sources. A request without a user identity runs with the data access role’s own permissions.
The following trust policy lets AWS Context assume the role and attach the user’s identity.
{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Principal": {"Service": "context.amazonaws.com"}, "Action": ["sts:AssumeRole", "sts:SetContext"], "Condition": {"StringEquals": {"aws:SourceAccount": "<your account ID>"}} }] }
The following example grants an IAM Identity Center user SELECT on every table in a database.
aws lakeformation grant-permissions \ --principal DataLakePrincipalIdentifier=arn:aws:identitystore:::user/<user ID> \ --permissions "SELECT" \ --resource '{ "Table": { "DatabaseName": "<database>", "TableWildcard": {} } }'
You can also use the user’s identity in IAM policy conditions. The following bucket policy denies one user access to a bucket, even through the data access role. aws:OriginIdentity/Subject is the subject that your identity provider sets for the user, such as a SAML NameID or an OIDC sub. It isn’t always an email address. Pair it with aws:OriginIdentity/Issuer.
{ "Version": "2012-10-17", "Statement": [{ "Sid": "DenyTipUser", "Effect": "Deny", "Principal": "*", "Action": "s3:*", "Resource": ["arn:aws:s3:::<bucket>", "arn:aws:s3:::<bucket>/*"], "Condition": {"StringEquals": { "aws:OriginIdentity/Issuer": "<identity provider issuer>", "aws:OriginIdentity/Subject": "<user subject>" }} }] }
For the context keys you can use, see TIP context keys and runtime claims for IAM federation in the IAM User Guide.
For Snowflake Horizon and Databricks Unity Catalog, set the connection’s credentialBroker settings (credentialProviderArn and scopes) so that the source checks each user’s own permissions. Set them in sourceConfig when you create the connection. For an existing AWS Glue connection, set CredentialBrokerProperties, with the grant type AUTHORIZATION_CODE, on the Glue connection. Each user authorizes AWS Context for each credential provider and set of scopes. Until a user does, AgenticRetrieve returns authorizationRequired with a single-use authorizationUrl, and SearchAgentContext and TraverseAgentContext leave out that source’s results. If you change the scopes, users must authorize again. For how each source controls access, see Overview of Access Control