Skip to content
agentgateway has joined the Agentic AI FoundationLearn more

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Page as Markdown

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.

IAM (SigV4) is the default. agentgateway signs each request with AWS Signature Version 4 (SigV4) by using the standard AWS credential lookup from the proxy’s environment, such as IRSA on Amazon EKS. You do not store long-lived credentials in the gateway configuration, and IRSA credentials rotate automatically.

Before you begin

Install and set up an agentgateway proxy.

Additionally, make sure that you have the following:

  1. 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>.
  2. 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
SettingDescription
aws.agentCore.agentRuntimeArnThe 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.qualifierOptional. The runtime version or endpoint qualifier to invoke. If you omit this setting, the default endpoint is used.
policies.authOptional. 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

  1. Create an HTTPRoute that routes incoming traffic to the AgentgatewayBackend. The following route matches the /agentcore path 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 /agentcore is 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-agent does not select a different agent. The my-agent subpath is dropped, and the request still reaches the ARN in the backend. To route to more than one runtime, create a separate AgentgatewayBackend (each with its own agentRuntimeArn) and a separate route for each one. To target a different version or endpoint of the same runtime, set aws.agentCore.qualifier instead.

    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
    EOF
  2. Optional: Add a RequestHeaderModifier filter to the route rule to identify the calling user to the AgentCore runtime. AgentCore uses the X-Amzn-Bedrock-AgentCore-Runtime-User-Id header 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

  1. 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_ADDRESS
  2. Send 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 403 error 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
Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.