Secure AI agents with Policy and Lambda interceptors in Amazon Bedrock AgentCore gateway Amazon Bedrock AgentCore gateway now supports Policy and Lambda interceptors to secure AI agent behavior, addressing the challenge of managing access to thousands of tools across enterprise platforms. The Policy mechanism provides deterministic access control using Cedar language policies, while Lambda interceptors enable dynamic validation, payload enrichment, and response filtering before or after tool calls. This layered security architecture allows organizations to enforce governance on LLM-powered agents that dynamically select tools at runtime, solving the auditing and compliance problems inherent in traditional fixed-logic applications. Artificial Intelligence https://aws.amazon.com/blogs/machine-learning/ Secure AI agents with Policy and Lambda interceptors in Amazon Bedrock AgentCore gateway Securing AI agent behavior is a key customer challenge in building agentic solutions. As enterprises rapidly adopt AI agents to automate workflows, they face a scaling challenge in managing secure access to tools across the organization. Modern unified enterprise AI platforms have hundreds of agents serving users across the organization. These agents need to access thousands of Model Context Protocol MCP tools spanning different teams, organizations, and business units. The scale of these platforms creates a fundamental governance problem. Traditional applications execute fixed logic. Agents powered by a large language model LLM decide at runtime which tools to invoke, with what arguments, and in what sequence. Because of the dynamic nature of this workflow, auditing the call graph in advance becomes a problem. You must build mechanisms for an LLM so that it behaves the way you intend. You can use Amazon Bedrock AgentCore gateway https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway.html to secure agents and tools through two complementary mechanisms: Policy in Amazon Bedrock AgentCore https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/policy.html for deterministic access control and interceptors for AgentCore gateway https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-interceptors.html for dynamic validation. Policy in Amazon Bedrock AgentCore lets you define policies on tools attached to your Gateway. Policies are authored in Cedar, a declarative policy language that evaluates each request against a principal , an action , and a resource , with optional conditions over request context. The result is a deterministic allow or deny decision, automatically recorded in the audit log. Lambda interceptors let you define custom code that runs before or after each tool call, supporting dynamic validation, payload enrichment, token exchange, and response filtering. You can combine both mechanisms to build a layered security architecture for your agentic solutions. In this post, we use a lakehouse data agent to demonstrate how you can use Policy for deterministic access control and Lambda interceptors for dynamic validation. We then show how to combine Lambda interceptors and Policy to implement a geography-based access control which requires both dynamic validation and deterministic access control. Prerequisites Before implementing this solution, you need: An AWS account https://aws.amazon.com/free/?trk=04d587d8-77d6-4750-bffa-2bc5a475e1a9&sc channel=ps&ef id=EAIaIQobChMI7NLH8eDRkwMVJ0n AR2 lTPDEAAYASAAEgKGlPD BwE:G:s&s kwcid=AL 4422 3 798517281036 e g create%20aws%20account 23610836392 199347046688&gad campaignid=23610836392&gclid=EAIaIQobChMI7NLH8eDRkwMVJ0n AR2 lTPDEAAYASAAEgKGlPD BwE .- Access to the GitHub repository https://github.com/awslabs/amazon-bedrock-agentcore-samples/tree/main/02-use-cases/lakehouse-agent . AWS Identity and Access Management IAM permissions https://docs.aws.amazon.com/IAM/latest/UserGuide/access policies.html to set up the prerequisites https://github.com/awslabs/amazon-bedrock-agentcore-samples/tree/main/02-use-cases/lakehouse-agent prerequisites . Solution overview The lakehouse data agent is an AI assistant that lets insurance company employees query claims data. The data is stored in Amazon S3 Tables https://aws.amazon.com/s3/features/tables/ Apache Iceberg and queried through Amazon Athena https://aws.amazon.com/athena/ and AWS Lake Formation https://aws.amazon.com/lake-formation/ . Three user roles exist in the application: policyholders who can only view their own claims , adjusters who manage assigned claims , and administrators who have full data access including audit logs . A Streamlit UI authenticates users through Amazon Cognito https://aws.amazon.com/cognito/ and passes JSON Web Tokens JWT to the agent. The MCP Server exposes five tools: query claims , get claim details , get claims summary , query login audit , and text to sql . Role-to-tool access, tenant IAM role mappings, and user geography are stored in Amazon DynamoDB. AWS Lake Formation enforces row-level and column-level security at query time. In this case, even if an agent constructs a broad SQL query, the results are automatically scoped to what the caller’s IAM role is permitted to see. The following diagram shows the architecture for the lakehouse data agent: Users access the lakehouse agent through a Streamlit UI, where Amazon Cognito authenticates them and issues bearer tokens. AgentCore Runtime hosts the lakehouse agent, validates these tokens, and establishes isolated sessions for each user. When the agent invokes tools, AgentCore Gateway routes requests through a Lambda Interceptor. The Interceptor extracts the bearer token, validates tool access through Tenant Role Mapping, and generates a token with tenant-scoped claims. The AgentCore Policy Engine evaluates each tool call against defined policies before permitting access. The lakehouse MCP Server then queries data using the scoped credentials. AWS Lake Formation enforces row-level and column-level security based on the Users Table and Claims Table, helping each user see only the data they are authorized to access. AgentCore Observability and Session Logs stream to Amazon CloudWatch for real-time monitoring and compliance auditing. Request flow The following diagram shows the tool call flow through the solution: When the lakehouse agent initiates a tool call through the AgentCore Gateway, the request is intercepted by the Request Interceptor Lambda function. The Request Interceptor transforms the request by replacing the bearer token with tenant-scoped credentials and injects additional context. The Policy Engine then evaluates the transformed request based on the Cedar policy. The transformed request is used to invoke the tool using the lakehouse MCP Server. The response is then evaluated by the Response Interceptor Lambda function, which filters the tool list before the response is returned to the user. The Gateway evaluates the request interceptor before the Cedar policy. This order is fundamental to the design patterns where you would use the interceptor to enrich the request context before using policy to evaluate that enriched context. Policy enforcement in AgentCore Gateway Policy in Amazon Bedrock AgentCore uses the Cedar policy language to enforce deterministic, auditable access control at the Gateway. Cedar policy is expressed as permit or forbid rules evaluated over a principal, an action, and a resource, with conditions based on the context of the action. We use Cedar policies for fine-grained access control when the authorization rules can be expressed as a logical condition over identity attributes, action identifiers, and request context. Typical use cases include restricting which tools a role can invoke and blocking access to sensitive operations for certain user groups. Cedar also enforces data-residency rules based on context attributes injected by an interceptor, and supports scope-checking or time-window enforcement at the gateway before requests reach downstream services. Design 1: Policy only First, let’s look at an example of a policy acting as a security layer for the lakehouse agent. Consider the scenario where the business decides that policyholders should not be able to call get claims summary . Policyholders can view their own individual claims, but the aggregate summary is reserved for adjusters and administrators. To do this, you can attach a Policy Engine to the Gateway https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/policy-getting-started.html and define two Cedar policies that work together: a baseline permit rule and a targeted forbid rule. When a Policy Engine is attached to a Gateway, it follows deny-by-default semantics. If no policy explicitly permits a request, it is denied. Therefore, you first need a baseline permit policy that allows the agent to invoke tools on the Gateway: permit principal, action, resource == AgentCore::Gateway::"