Enable Amazon Bedrock Agents for Cross-Account Access

Introduction

As organizations increasingly rely on artificial intelligence (AI) to drive decision-making, seamless access to structured data becomes essential. Amazon Bedrock agents offer powerful capabilities for building intelligent assistants, but integrating these agents with data spread across multiple AWS accounts can be challenging. This article explores a secure and scalable architecture for enabling Amazon Bedrock agents to connect to Amazon Redshift-based knowledge bases located in different AWS accounts.

The Integration Challenge

Enterprises often adopt a multi-account strategy to maintain separation of concerns, improve security, and manage access controls. However, Amazon Bedrock Knowledge Bases do not natively support cross-account integration with Amazon Redshift. This limitation creates barriers for organizations that wish to:

  • Leverage existing Redshift data for AI agents
  • Preserve account isolation
  • Avoid data duplication
  • Maintain strong security and access controls

Proposed Solution Overview

The solution presented here uses a serverless and secure architecture that bridges the communication gap between Amazon Bedrock agents and Redshift-based knowledge bases in another AWS account. This is achieved using AWS Lambda functions and IAM roles to facilitate cross-account access.

The workflow includes the following steps:

  1. A user submits a query via an Amazon Bedrock agent in the agent account.
  2. The agent triggers a Lambda function through an action group.
  3. The Lambda function assumes an IAM role in the agent-kb account to access the Redshift-based knowledge base.
  4. The knowledge base uses another IAM role to query the Amazon Redshift serverless workgroup and return structured data.

Key Components of the Architecture

  • Amazon Bedrock Agent: Handles user interactions in the agent account.
  • Amazon Redshift Serverless: Hosts structured data in a private VPC within the agent-kb account.
  • Amazon Bedrock Knowledge Base: Configured to use Redshift as the data source.
  • AWS Lambda: Acts as an intermediary, invoked by the agent to query the knowledge base.
  • IAM Roles and Policies: Securely manage cross-account access permissions.

Prerequisites

Before implementing this solution, ensure the following are in place:

  • Two AWS accounts (agent and agent-kb)
  • AWS CLI (version 2.24.22 or later)
  • jq command-line JSON parser installed
  • IAM user credentials configured for CLI access
  • Model access enabled in the us-west-2 Region for:
    • meta.llama3-1-70b-instruct-v1:0 (agent-kb)
    • us.amazon.nova-pro-v1:0 (agent)

Implementation Steps

1. Create Redshift Workgroup and Knowledge Base

Log in to the agent-kb account and set up a Redshift Serverless workgroup in a private subnet. Create a knowledge base pointing to this Redshift instance and train your AI assistant accordingly.

2. Configure IAM Roles and Policies

Use the provided shell script create_bedrock_agent_kb_roles_policies.sh to establish necessary IAM roles and policies that enable secure Lambda-to-Redshift communication across accounts.

3. Deploy Bedrock Agent via CloudFormation

In the agent account, use the CloudFormation template cloudformation_bedrock_agent_kb_query_cross_account.yaml to create:

  • Amazon Bedrock Agent
  • Action Group
  • Lambda function with OpenAPI integration
  • Necessary IAM roles and policies

4. Verify Model Access

Ensure model access for both accounts through the Amazon Bedrock console. Missing access must be enabled before testing the solution.

5. Run and Test the Agent

Navigate to the Bedrock console in the agent account, select your agent, and begin testing natural language queries such as:

  • “Who are the top 5 customers in Saudi Arabia?”
  • “What is the total revenue by region for the year 1998?”
  • “Show me orders with the highest priority from Q4 1997.”

Use the Show trace option to debug and optimize queries.

Best Practices

  • Use precise and domain-specific terminology
  • Phrase questions based on existing dataset schema
  • Apply Amazon Bedrock Guardrails for safe outputs

Resource Cleanup

To avoid unnecessary charges, clean up resources after use. Delete CloudFormation stacks in both accounts and remove associated S3 buckets manually. Use the delete-bedrock-agent-kb-roles-policies.sh script to remove IAM roles and policies.

Conclusion

This solution effectively enables cross-account querying capabilities for Amazon Bedrock agents by leveraging serverless technologies and strong IAM policies. It allows organizations to maintain a secure, scalable, and modular architecture while improving the utility of existing structured data in Redshift.

As Amazon Bedrock evolves, this approach facilitates easier integration with emerging features while supporting multi-account best practices.


This article is inspired by content from Original Source. It has been rephrased for originality. Images are credited to the original source.

Subscribe to our Newsletter