For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Connect to AWS Bedrock AgentCore
Route requests to an Amazon Bedrock AgentCore agent runtime through agentgateway.
With agentgateway, you can route requests directly to an Amazon Bedrock AgentCore agent runtime by using an AgentgatewayBackend resource. You do not need a separate proxy, custom code, or the AWS SDK.
About AWS Bedrock AgentCore
Amazon Bedrock AgentCore is a runtime that hosts deployed agents, each with its own invocation endpoint. To reach an AgentCore runtime, you supply its Amazon Resource Name (ARN) to an AgentgatewayBackend of type aws. agentgateway uses the ARN to determine where to send each request. It connects over TLS to the bedrock-agentcore endpoint in the runtime’s AWS region, then rewrites the request path to target the specific runtime. You do not construct the endpoint or encode the ARN yourself.
Authentication
AgentCore runtimes support two authentication modes, which you choose when you deploy the runtime in AWS. The aws.agentCore backend supports both IAM (SigV4) and JWT authorization.
Before you begin
Install and set up an agentgateway proxy.Additionally, make sure that you have the following:
- An Amazon Bedrock AgentCore agent runtime that is deployed in your AWS account. For steps to build and deploy a runtime, see the Amazon Bedrock AgentCore documentation. You also need the runtime’s ARN, in the format
arn:aws:bedrock-agentcore:<region>:<account-id>:runtime/<runtime-id>. - Credentials for the runtime’s authentication mode.For IAM (SigV4), AWS credentials that are available to the agentgateway proxy and that are allowed to invoke the runtime. The proxy uses the standard AWS credential chain, such as an IAM role, environment variables, or an instance profile. On Amazon EKS, the recommended approach is IAM Roles for Service Accounts (IRSA): associate an IAM role with the proxy’s Kubernetes service account.
Step 1: Create a backend for the AgentCore runtime
Create an AgentgatewayBackend resource that represents the AgentCore runtime. The aws.agentCore settings point agentgateway to the runtime that you want to invoke. The configuration depends on the runtime’s authentication mode.
Create the backend with only the aws.agentCore settings. Agentgateway signs each request with SigV4 by using the proxy’s environment credentials. You do not add an authentication policy.
kubectl apply -f- <<EOF
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayBackend
metadata:
name: agentcore-backend
namespace: agentgateway-system
spec:
aws:
agentCore:
agentRuntimeArn: arn:aws:bedrock-agentcore:us-west-2:111122223333:runtime/my-agent-runtime
# qualifier: production
EOF| Setting | Description |
|---|---|
aws.agentCore.agentRuntimeArn | The ARN of the AgentCore agent runtime to invoke, in the format arn:aws:bedrock-agentcore:<region>:<account-id>:runtime/<runtime-id>. agentgateway derives the endpoint, region, and invocation path from this value. |
aws.agentCore.qualifier | Optional. The runtime version or endpoint qualifier to invoke. If you omit this setting, the default endpoint is used. |
policies.auth | Optional. Overrides the default authentication for the backend. Omit this setting to sign requests with SigV4 (IAM). To authenticate to a runtime that uses a JWT authorizer, set policies.auth.secretRef (or policies.auth.key) to a bearer token. By default, the token is sent in the Authorization header with a Bearer prefix. When you use secretRef with the default resolver, store the token under the Secret’s Authorization key. |
Step 2: Route to the AgentCore backend
Create an HTTPRoute that routes incoming traffic to the
AgentgatewayBackend. The following route matches the/agentcorepath so that the runtime has a unique address on the gateway. You do not need to rewrite the path, because agentgateway replaces the entire request path with the runtime’s invocation endpoint before the request is sent upstream. As a result, any subpath that a client appends after/agentcoreis not forwarded to the runtime.Note
AgentCore identifies a runtime entirely by its ARN, not by a URL subpath, so a path such as
/agentcore/my-agentdoes not select a different agent. Themy-agentsubpath is dropped, and the request still reaches the ARN in the backend. To route to more than one runtime, create a separateAgentgatewayBackend(each with its ownagentRuntimeArn) and a separate route for each one. To target a different version or endpoint of the same runtime, setaws.agentCore.qualifierinstead.kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: agentcore namespace: agentgateway-system spec: parentRefs: - name: agentgateway-proxy namespace: agentgateway-system rules: - matches: - path: type: PathPrefix value: /agentcore backendRefs: - name: agentcore-backend group: agentgateway.dev kind: AgentgatewayBackend EOFOptional: Add a
RequestHeaderModifierfilter to the route rule to identify the calling user to the AgentCore runtime. AgentCore uses theX-Amzn-Bedrock-AgentCore-Runtime-User-Idheader to associate requests with a user session.filters: - type: RequestHeaderModifier requestHeaderModifier: set: - name: X-Amzn-Bedrock-AgentCore-Runtime-User-Id value: user-123
Step 3: Verify the connection
Get the agentgateway address.
export INGRESS_GW_ADDRESS=$(kubectl get gateway agentgateway-proxy -n agentgateway-system -o=jsonpath="{.status.addresses[0].value}") echo $INGRESS_GW_ADDRESSSend a request to the AgentCore runtime through the gateway. The request body depends on the agent that you deployed to the runtime. The following example sends a simple prompt.
curl -X POST http://$INGRESS_GW_ADDRESS/agentcore \ -H "Content-Type: application/json" \ -d '{"prompt": "Hello from agentgateway!"}'Example output:
{"result": {"role": "assistant", "content": [{"text": "Hello! 👋 \n\nNice to meet you! I'm Claude, an AI assistant made by Anthropic. I'm here to help with a wide variety of tasks—whether that's answering questions, helping with writing, coding, analysis, creative projects, math, or just having a conversation.\n\nWhat can I help you with today?"}]}}If the runtime is reachable and the request is authenticated, you get a response from your agent. A
403error indicates an authentication problem:- For IAM, verify that the proxy’s AWS credentials are allowed to invoke the runtime.
- For a JWT authorizer, verify that the token in the Secret is valid and not expired. Also make sure that the AgentCore runtime is set up with the Inbound Auth details that match the IdP, such as the discovery URL and client ID.
Cleanup
You can remove the resources that you created in this guide.kubectl delete HTTPRoute agentcore -n agentgateway-system --ignore-not-found
kubectl delete AgentgatewayBackend agentcore-backend -n agentgateway-system --ignore-not-found
kubectl delete secret agentcore-jwt -n agentgateway-system --ignore-not-found