For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
AWS backend authentication
Sign requests to an AWS service with AWS Signature Version 4, optionally through an assumed IAM role.
Verified Code examples on this page have been automatically tested and verified.Attaches to:
Configuration examples
To sign requests to an AWS service, use aws. Unlike the other methods, aws does not attach a token. It computes an AWS Signature Version 4 signature over the request, so it runs last, after every other policy that changes the request.
Name an access key explicitly, or omit the credential fields to use the standard AWS credential chain.
backendAuth:
aws:
accessKeyId: "$AWS_ACCESS_KEY_ID"
secretAccessKey: "$AWS_SECRET_ACCESS_KEY"
sessionToken: "$AWS_SESSION_TOKEN"
region: us-west-2
serviceName: execute-apibackendAuth:
aws:
region: us-east-1
serviceName: bedrock| Field | Description |
|---|---|
accessKeyId and secretAccessKey | An explicit access key. Set both together, or omit both to use the credential chain. |
sessionToken | Session token that goes with a temporary access key. |
region | Signing region, such as us-east-1. Set the field when the target service is in a different region from agentgateway. A typed AWS backend may supply the region on its own. |
serviceName | Signing service name, such as bedrock, bedrock-agentcore, or execute-api. The field can be any AWS SigV4 signing name, and agentgateway does not validate it against a list. The signing name is the service element of the credential scope, which the AWS Signature Version 4 signing elements documentation describes. A typed AWS backend may supply the name on its own. |
assumeRole | IAM role to assume before signing. Available with the credential chain only, so do not set an access key alongside it. |
AWS credential resolution order
When you omit accessKeyId and secretAccessKey, agentgateway uses the default credential chain of the AWS SDK. The chain tries the following sources in order and stops at the first one that returns credentials.
- Environment variables:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, andAWS_SESSION_TOKEN. - Shared configuration files:
~/.aws/configand~/.aws/credentials. - Web identity token:
AWS_WEB_IDENTITY_TOKEN_FILEandAWS_ROLE_ARN. This is the source that IAM roles for service accounts and EKS Pod Identity use. - Container credentials: the credential endpoint that Amazon ECS and other container hosts provide.
- Instance metadata: IMDSv2 on an EC2 instance.
Assume a role
To sign with a role rather than with the identity of agentgateway, set assumeRole. Agentgateway calls the AWS Security Token Service (STS) with the credentials from the chain, and signs with the credentials that STS returns. It caches the assumed credentials and refreshes them before they expire.
Create the IAM role in AWS before you set the field. The role needs a permissions policy that allows the actions of the service that you call, such as bedrock:InvokeModel for Amazon Bedrock. It also needs a trust policy that allows the identity of agentgateway to assume it. Which permissions you attach therefore depends on the service that the backend fronts. For the steps, see Create a role to delegate permissions to an AWS service in the AWS documentation.
The session name and the session tags exist for cost attribution. Each accepts a static value, or a CEL expression that agentgateway evaluates against every request, which lets one gateway attribute cost per user or per team.
backendAuth:
aws:
region: us-east-1
serviceName: bedrock
assumeRole:
roleArn: arn:aws:iam::123456789012:role/agentgateway-bedrock
sessionName:
expression: jwt.sub
tags:
- key: team
value: platform
- key: user
expression: jwt.sub| Field | Description |
|---|---|
assumeRole.roleArn | Required ARN of the IAM role to assume. |
assumeRole.sessionName | Session name (RoleSessionName) that appears in AWS CloudTrail and in the Cost and Usage Report. Either a static string, or {expression: <cel>}. Two to 64 characters, matching [\w+=,.@-]. Omit the field and AWS generates a random name. |
assumeRole.tags | Session tags that agentgateway passes to STS. Each tag sets key, plus exactly one of value for a static value or expression for a CEL expression. STS allows at most 50 tags for one role session. |
Note
A session tag reaches the Cost and Usage Report as resourceTags/user:<TagKey>, but only after you activate the tag key as a cost allocation tag in the AWS Billing console.
Warning
A CEL expression that does not produce a valid session name or tag value at request time causes agentgateway to reject that request. An expression such as jwt.sub therefore makes the route depend on a client authentication policy that populates the JWT claims. The failure is per-request, and --validate-only does not catch it.