← Stories · Brief

Secure AI agents with Amazon Bedrock AgentCore Identity on Amazon ECS

The article outlines a method for securing AI agents deployed on Amazon ECS using Amazon Bedrock AgentCore Identity. It details the implementation of the Authorization Code Grant (3-legged OAuth) flow, ensuring secure session binding and scoped access tokens for external service interactions. This approach addresses critical security concerns for production AI agents by enforcing least-privilege principles and protecting against common web attacks.

aws-machine-learning-blog engineering-technology May 5, 2026 source →
Claims
121
Domain
engineering-technology
Reading time
9 min
Record
Secure AI agents with Amazon Bedrock AgentCore Identity on A

Claims from this story

Every atomic assertion extracted from the underlying record, ranked by evidence strength.

Amazon Bedrock AgentCore Identity secures how AI agents access external services.

direct_quotestatedengineering-technologyMay 5, 2026

The implementation includes auth tokens scoped to each user session, following least-privilege principles.

direct_quotestatedengineering-technologyMay 5, 2026

The implementation includes secure session binding that prevents CSRF and browser-swapping attacks.

direct_quotestatedengineering-technologyMay 5, 2026

The Session Binding Service processes OAuth callbacks to link user sessions with third-party access tokens.

direct_quotestatedengineering-technologyMay 5, 2026

The implementation includes separation of concerns between the agent workload and session binding service.

direct_quotestatedengineering-technologyMay 5, 2026

The solution uses OAuth 2.0 (RFC 6749) and OpenID Connect (OIDC).

direct_quotestatedengineering-technologyMay 5, 2026

AI agents in production require secure access to external services.

direct_quotestatedengineering-technologyMay 5, 2026

The access logs bucket requires Amazon S3 managed encryption (SSE-S3).

direct_quotestatedengineering-technologyMay 5, 2026

The solution maintains an auditable chain from user authentication through to agent action.

direct_quotestatedengineering-technologyMay 5, 2026

This post implements Authorization Code Grant (3-legged OAuth) on Amazon ECS with secure session binding and scoped tokens.

direct_quotestatedengineering-technologyMay 5, 2026

The Authorization Code Grant provides user consent before the agent can act.

direct_quotestatedengineering-technologyMay 5, 2026

The Authorization Code Grant provides scoped delegation that limits the agent to only the permissions the user approved.

direct_quotestatedengineering-technologyMay 5, 2026

A Callback URL points to AgentCore Identity and must be registered with the Authorization Server as the redirect target.

direct_quotestatedengineering-technologyMay 5, 2026

OIDC authenticates users (who they are).

direct_quotestatedengineering-technologyMay 5, 2026

The pattern works across different compute platforms, whether you run agents on ECS, EKS, Lambda, or outside AWS entirely.

direct_quotestatedengineering-technologyMay 5, 2026

The application exchanges an authorization code for an access token, which creates an audit trail.

direct_quotestatedengineering-technologyMay 5, 2026

The Authorization Code Grant flow involves a user authenticating with an identity provider and granting consent.

direct_quotestatedengineering-technologyMay 5, 2026

AI agents can run on compute platforms like Amazon ECS, Amazon EKS, AWS Lambda, or on-premises.

direct_quotestatedengineering-technologyMay 5, 2026

Amazon Bedrock AgentCore Identity secures the scoped access token in its token vault.

direct_quotestatedengineering-technologyMay 5, 2026

Each token is bound to a specific user identity with explicit consent.

direct_quotestatedengineering-technologyMay 5, 2026

The `sub` field in the JWT uniquely identifies the user.

direct_quotestatedengineering-technologyMay 5, 2026

The Authorization Code Grant is suited for agentic workloads that act on behalf of users.

direct_quotestatedengineering-technologyMay 5, 2026

The agent calls a large language model (LLM) on Amazon Bedrock.

direct_quotestatedengineering-technologyMay 5, 2026

The Authorization Code Grant provides session binding that verifies the user who initiated the authorization request is the same user who granted consent.

direct_quotestatedengineering-technologyMay 5, 2026

Performing actions in GitHub requires the user's OAuth access token.

direct_quotestatedengineering-technologyMay 5, 2026

A Callback URL is automatically generated when creating an OAuth client in AgentCore Identity.

direct_quotestatedengineering-technologyMay 5, 2026

After user authorization, the Session Binding Service completes the OAuth flow by binding the authorization to the correct user session via AgentCore Identity.

direct_quotestatedengineering-technologyMay 5, 2026

A Session Binding URL points back to a customer-managed service that completes the session binding between the authenticated user and the OAuth flow.

direct_quotestatedengineering-technologyMay 5, 2026

The Session Binding URL endpoint is implemented and hosted by the customer.

direct_quotestatedengineering-technologyMay 5, 2026

The architecture diagram shows AgentCore Identity securing a self-hosted AI agent on Amazon ECS.

direct_quotestatedengineering-technologyMay 5, 2026

The Agentic Workload runs the AI agent and handles user requests.

direct_quotestatedengineering-technologyMay 5, 2026

The solution deploys two services on Amazon ECS behind an Application Load Balancer.

direct_quotestatedengineering-technologyMay 5, 2026

The solution focuses on the Authorization Code Grant for user-delegated access.

direct_quotestatedengineering-technologyMay 5, 2026

Other OIDC-compliant providers are supported by the solution.

direct_quotestatedengineering-technologyMay 5, 2026

The walkthrough uses Microsoft Entra ID as the identity provider.

direct_quotestatedengineering-technologyMay 5, 2026

Both services use Amazon Bedrock AgentCore Identity to authenticate users inbound via OIDC and authorize outbound actions on their behalf.

direct_quotestatedengineering-technologyMay 5, 2026

Requests arrive at an Amazon Application Load Balancer (ALB).

direct_quotestatedengineering-technologyMay 5, 2026

The ALB authenticates the user through the ALB's built-in OIDC authentication flow.

direct_quotestatedengineering-technologyMay 5, 2026

Traffic is encrypted with HTTPS using a certificate from AWS Certificate Manager.

direct_quotestatedengineering-technologyMay 5, 2026

An alias A record in an Amazon Route 53 public hosted zone routes traffic to the load balancer.

direct_quotestatedengineering-technologyMay 5, 2026

After authenticating the user through OIDC, the ALB forwards the request to the Amazon ECS cluster.

direct_quotestatedengineering-technologyMay 5, 2026

The ALB injects an x-amzn-oidc-data header containing the user's claims in JWT format.

direct_quotestatedengineering-technologyMay 5, 2026

OAuth 2.0 authorizes user actions (what they can do).

direct_quotestatedengineering-technologyMay 5, 2026

The Agentic Workload exposes a FastAPI server with an `/invocations` endpoint that accepts a `sessionId` and `message`.

direct_quotestatedengineering-technologyMay 5, 2026

The FastAPI server passes `sessionId` and `message` to an agent built with Strands Agents.

direct_quotestatedengineering-technologyMay 5, 2026

Other agent SDKs like LangChain can also be used.

direct_quotestatedengineering-technologyMay 5, 2026

Amazon Bedrock AgentCore Identity is available as a standalone service.

direct_quotestatedengineering-technologyMay 5, 2026

Other model providers work with the agent.

direct_quotestatedengineering-technologyMay 5, 2026

The agent uses the user's `sub` claim as a key prefix to isolate sessions between users.

direct_quotestatedengineering-technologyMay 5, 2026

The agent has tools to perform actions on the user's behalf in GitHub.

direct_quotestatedengineering-technologyMay 5, 2026

The solution validates the ALB-signed JWT using AWS's published signing keys.

direct_quotestatedengineering-technologyMay 5, 2026

When the agent needs to act on a user's behalf in a third-party service, it requests an OAuth access token through AgentCore Identity.

direct_quotestatedengineering-technologyMay 5, 2026

If no valid token exists, AgentCore Identity initiates an Authorization Code Grant flow.

direct_quotestatedengineering-technologyMay 5, 2026

The Authorization Code Grant flow prompts the user to authorize access.

direct_quotestatedengineering-technologyMay 5, 2026

A dedicated S3 bucket stores access logs for both the load balancer and the data bucket.

direct_quotestatedengineering-technologyMay 5, 2026

The FastAPI server that hosts the agentic workload exposes a `/docs` endpoint, which renders the OpenAPI specification as an interactive HTML page.

direct_quotestatedengineering-technologyMay 5, 2026

Amazon CloudWatch captures logs.

direct_quotestatedengineering-technologyMay 5, 2026

ECS pulls container images from Amazon ECR.

direct_quotestatedengineering-technologyMay 5, 2026

A set of basic AWS WAF rules is attached to the load balancer to provide baseline protection against common web exploits.

direct_quotestatedengineering-technologyMay 5, 2026

The agent stores session state in an Amazon S3 bucket.

direct_quotestatedengineering-technologyMay 5, 2026