

# Connect an agent context to Quick

You can attach an existing agent context from AWS Context to AWS Quick. After you attach it, users can ask questions in Quick chat, and Quick retrieves answers from the data in your agent context, using each user's own access permissions.

The agent context can be in the same AWS account as your Quick account, or in a different account.

This guide covers the Quick side. It assumes you already created an agent context in AWS Context.

**Topics**
+ [Supported AWS Regions](#connect-agent-context-regions)
+ [Prerequisites](#connect-agent-context-prerequisites)
+ [Attach the agent context](#connect-agent-context-attach)
+ [Change the agent context](#connect-agent-context-change)
+ [Detach the agent context](#connect-agent-context-detach)
+ [Use the agent context in Quick chat](#connect-agent-context-use-in-chat)
+ [Data source access](#connect-agent-context-data-access)
+ [Trusted identity propagation](#connect-agent-context-tip)
+ [Cross-account access](#connect-agent-context-cross-account)

## Supported AWS Regions
<a name="connect-agent-context-regions"></a>

You can connect an agent context to Quick in the following AWS Regions:
+ US East (N. Virginia)
+ US West (Oregon)
+ Europe (Ireland)

## Prerequisites
<a name="connect-agent-context-prerequisites"></a>

Before you attach an agent context, make sure that you have the following:
+ A Quick account in one of the supported Regions
+ An agent context with its data connections configured and synced
+ The ARN of the agent context
+ Quick administrator access

## Attach the agent context
<a name="connect-agent-context-attach"></a>

**To attach an agent context to Quick**

1. Open AWS Quick at [https://quicksight.aws.amazon.com/](https://quicksight.aws.amazon.com/).

1. Choose **Sign in to Quick** and sign in as an administrator.

1. Open the admin landing page for your account in the same Region as the agent context: `https://{{REGION}}.quicksight.aws.amazon.com/sn/account/{{account-name}}/admin/landing`, where {{REGION}} is the Region of your agent context and {{account-name}} is your Quick account (subscription) name.

1. On the admin page, choose **AWS Resources**.

1. Find the **AWS Context** entry and choose **Add Agent Context**.

1. Enter the ARN of the agent context.

1. Choose **Save**.

When you save, Quick sets up the access it needs in your account to read from the agent context that you specified. Agent context tools can take up to 15 minutes to become available in Quick chat.

**Note**  
If your agent context connects to third-party data sources through Credential Broker, you must tag each Credential Broker instance with the following key-value pair. The key and value must match exactly; without this tag, Quick can't access the instances.  

Key  
`QuickSightContextAccess`

Value  
`true`

## Change the agent context
<a name="connect-agent-context-change"></a>

**To point Quick at a different agent context**

1. Open the admin **AWS Resources** page for your account.

1. Edit the agent context ARN.

1. Choose **Save**.

## Detach the agent context
<a name="connect-agent-context-detach"></a>

**To detach the agent context**

1. On the admin **AWS Resources** page, clear the **AWS Context** checkbox.

1. Choose **Save**.

Quick no longer has access to your agent context.

## Use the agent context in Quick chat
<a name="connect-agent-context-use-in-chat"></a>

After you attach the agent context, users can ask questions in Quick chat that require its data, and Quick searches and traverses the agent context to answer them.

Each user can turn agent context capabilities on or off for themselves.

**To set agent context capabilities for your account**

1. On the home page, choose **Customize**.

1. Choose **Connectors**.

1. Choose **AWS Context**.

1. Enable or disable each capability (search, explore, and ask).

1. For each enabled capability, choose **Ask each time**, **Always allow**, or **Always deny**.

This setting is per user, and it appears only after an administrator attaches an agent context to Quick.

## Data source access
<a name="connect-agent-context-data-access"></a>

Quick accesses your agent context through a Quick-managed role, `aws-quicksight-context-role-v0`, that has permissions only to AWS Context, not to your underlying data sources. Whether a data connection returns results in Quick depends on the credential model that you chose for that connection in AWS Context.

### Connections that use a data access role
<a name="connect-agent-context-data-access-role"></a>

If a data connection uses a data access role, it works with Quick without additional setup. AWS Context assumes the data access role, which carries the data-source permissions. Where the source supports it, AWS Context propagates each user's identity for per-user authorization. The `aws-quicksight-context-role-v0` role needs no changes.

### Connections that use caller credentials
<a name="connect-agent-context-data-access-caller"></a>

If a data connection uses caller credentials, AWS Context queries the data source with the credentials of the caller. On the Quick path, the caller is the `aws-quicksight-context-role-v0` role, which has no data-source permissions by default. The connection returns no results until you grant that role access. To grant access, add an inline policy to `aws-quicksight-context-role-v0` that allows the actions the connection needs on the data source.

**Important**  
We recommend that you add the permissions as an inline policy on `aws-quicksight-context-role-v0`. Adding them as a managed policy, or modifying the AWS Context managed policy on the role, can prevent Quick from updating the role later, for example when you change the agent context ARN.  
All Quick access to this account's agent contexts shares the `aws-quicksight-context-role-v0` role. Permissions that you add apply to every user who queries through Quick, bounded only where the data source enforces the propagated end-user identity. Grant least privilege.

## Trusted identity propagation
<a name="connect-agent-context-tip"></a>

**Note**  
For a complete overview of trusted identity propagation in AWS Quick, see [Trusted identity propagation in AWS Quick](trusted-identity-propagation.md).

Quick uses trusted identity propagation (TIP) to pass the identity of the user who makes a request through to AWS Context. This lets AWS Context enforce per-user access to your data. For example, AWS Context applies access control lists (ACLs) for Amazon Bedrock knowledge bases and AWS Lake Formation permissions for AWS Glue Data Catalog tables, as well as the permissions of other data sources connected to your agent context. Each user sees only the data that they are permitted to access.

If your Quick account uses IAM Identity Center, Quick can pass user identity to AWS Context only if you do one of the following:
+ In the IAM Identity Center console, choose **Settings**, and under **Simplified experience for trusted identity propagation**, choose **Enable**.
+ Have an identity propagation configuration set for your Quick account.

If you don't have an identity propagation configuration, AWS Context returns only public documents, or none at all, for IAM Identity Center users.

**To check whether your account has an identity propagation configuration**
+ Run the following AWS CLI command. Replace {{111122223333}} with your AWS account ID and {{REGION}} with your Region:

  ```shell
  aws quicksight list-identity-propagation-configs --aws-account-id {{111122223333}} --region {{REGION}}
  ```

If the command returns a configuration, no further action is needed. Any identity propagation configuration lets Quick propagate user identity. If it returns none, create one.

**To create an identity propagation configuration**
+ Run the following AWS CLI command once. It uses the service `GLUE_DATA_CATALOG` and no authorized targets. Replace {{111122223333}} with your AWS account ID and {{REGION}} with your Region:

  ```shell
  aws quicksight update-identity-propagation-config --aws-account-id {{111122223333}} --service GLUE_DATA_CATALOG --region {{REGION}}
  ```

## Cross-account access
<a name="connect-agent-context-cross-account"></a>

If your agent context is in a different AWS account than your Quick account, add a resource policy to the agent context that allows the Quick agent context role in your Quick account to access it.

**To configure cross-account access**

1. Attach the agent context to Quick as described in [Attach the agent context](#connect-agent-context-attach). Quick creates the role in your Quick account when you save.

1. In the account that owns the agent context, add the following resource policy, replacing the placeholder values with your values:

   ```json
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Sid": "AllowQuickAgentContextAccess",
         "Effect": "Allow",
         "Principal": {
           "AWS": "arn:aws:iam::{{111122223333}}:role/service-role/aws-quicksight-context-role-v0"
         },
         "Action": [
           "context:GetAgentContext",
           "context:SearchAgentContext",
           "context:TraverseAgentContext",
           "context:AgenticRetrieve",
           "context:AgenticRetrieveStream"
         ],
         "Resource": "arn:aws:context:{{REGION}}:{{444455556666}}:agent-context/{{my-agent-context-id}}"
       }
     ]
   }
   ```

Replace the placeholder values as follows:
+ {{111122223333}} is the Quick account ID, the account that owns the Quick agent context role.
+ {{444455556666}} is the account that owns the agent context.
+ {{my-agent-context-id}} is the ID portion of the agent context ARN.
+ {{REGION}} is the Region of your agent context.

These two accounts are intentionally different, because this is cross-account access.

The following AWS CLI command adds the policy, replacing the placeholder values with your values:

```shell
aws context put-resource-policy --region {{REGION}} --resource-arn arn:aws:context:{{REGION}}:{{444455556666}}:agent-context/{{my-agent-context-id}} --policy file://policy.json
```

**Note**  
If you delete and recreate the Quick agent context role, update the resource policy so that it refers to the new role.