View a markdown version of this page

Caller-value references - Amazon Bedrock AgentCore

Caller-value references

Use a caller-value reference to compare a record’s metadata field with the caller’s own value. As a result, one statement can serve every department or group. You write a reference as {"ref": "<caller field>"} in place of a literal operand. A reference is a typed comparison, not text substitution.

The following field test compares each record’s department label with the caller’s department principal tag.

"customMetadata/department": { "StringEquals": { "ref": "iam:principalTag/department" } }

For complete configurations that use references, see Grant records of the caller’s department and Grant records labeled with any of the caller’s groups.

Reference syntax and permitted positions

A reference is a JSON object with one member, ref, whose value is a caller field name. It must be the whole operand of StringEquals or StringEqualsIfExists on a Text, Enum, or URL metadata field. The following table shows which positions validation accepts.

Position Accepted

The whole operand of StringEquals or StringEqualsIfExists on a Text, Enum, or URL metadata field

Yes

A test on a caller field, in principal

No

A test on recordType, name, or recordId

No

The operand of any other operator, such as StringNotEquals or Bool

No

A test on a Boolean metadata field

No

An entry in a list, alone or beside literal values

No

The service doesn’t substitute variables in strings. A string in variable syntax, such as "${iam:principalTag/department}", isn’t a reference. The service compares it as literal text, so it matches only a label with exactly that text.

A reference target must be one of the caller fields in the following table. The target must also belong to the registry’s identity family. This requirement applies even in a statement whose principal is "*". As a result, one configuration can’t mix AWS Identity and Access Management (IAM) and JSON Web Token (JWT) targets.

Caller field Accepted as a target Registry

iam:principalTag/<key>

Yes

IAM authorization

jwt:claim/<name>, jwt:scopes, or jwt:audiences

Yes

JWT authorization

iam:accountId, iam:principalArn, or iam:organizationId

No

Not applicable

jwt:claim/scope, jwt:claim/scp, or jwt:claim/aud

No. These field names are rejected everywhere.

Not applicable

Compare labels with caller values

A reference reads the caller’s value in whichever shape the caller presents it. A present single value supplies one comparison value, and a supported array supplies its distinct values. The record matches when its label exactly equals any of them. For the values that each caller field can supply, including how numbers and Booleans convert to strings, see Supported caller values.

For example, a JWT registry has three approved records: finance-mcp labeled department=finance, legal-agent labeled department=legal, and unlabeled-mcp with no department label. A statement in its configuration has the following resource test, and the statement’s other tests match.

"customMetadata/department": { "StringEquals": { "ref": "jwt:claim/groups" } }

The following table shows which records the test matches for different groups claims. The record unlabeled-mcp matches none of them.

Caller’s groups claim Records that the test matches

"finance"

finance-mcp

["finance"]

finance-mcp

["finance", "legal"]

finance-mcp and legal-agent

The following rules also apply when a reference compares values:

  • A reference accepts a single value or a set, so it doesn’t fix a claim’s cardinality. It also doesn’t make a principal test a membership test: "jwt:claim/groups": {"StringEquals": "finance"} still never matches ["finance"]. For more information, see Combining operators and choosing claim cardinality.

  • A referenced number or Boolean compares in its string form. For example, a claim value of 1.0 matches the label 1, and true matches the Text label true. A Boolean metadata field still can’t take a reference.

  • An empty string is a value. A caller value that is a present empty string matches a present empty label.

Missing referenced values

A reference needs a caller value. If the referenced caller field is missing or has no supported value, the whole statement is inapplicable. This holds in an Allow statement and a Deny statement alike, and even when the statement’s principal is "*". It also holds when the record test is StringEqualsIfExists, which otherwise matches a record that lacks the label.

A missing caller value differs from a missing record label and from an empty string. The following table shows the result of a test with the reference {"ref": "iam:principalTag/department"} on the department metadata field. The results are the same in Allow and Deny statements.

Caller’s department tag Record’s department label With StringEquals With StringEqualsIfExists

finance

finance

Match

Match

finance

legal

No match

No match

finance

Absent

No match

Match

A present empty value

A present empty label

Match

Match

Absent, or no supported value

Any label, or absent

Statement inapplicable

Statement inapplicable

A match takes effect only when the statement’s other tests also match. Then an Allow statement grants the record, and a Deny statement hides it. For how inapplicable statements fit into the decision, see Does a statement match?.

A Deny statement that references a missing caller value has no effect

A missing referenced value makes the whole statement inapplicable. As a result, a Deny statement that references a missing caller value has no effect. The statement doesn’t exclude a caller who lacks the attribute, or whose identity provider sends it in an unsupported shape. A missing value doesn’t match everything, and it can’t stand in for a universal exclusion. To hide records from every caller, write the Deny statement with a principal of "*" and no references. If callers without the attribute must discover nothing, require the attribute. Use "Exists": true in the principal of every Allow statement. For an example, see Combined grants and Deny precedence.

Reference limits and overflow

Two limits apply to references, at different times:

  • When you set the configuration – A configuration can contain a limited number of reference occurrences. Each occurrence counts, including repeats of the same caller field. For how the service counts, see Counting configuration limits.

  • On each discovery request – Each referenced caller field can supply a limited number of distinct values. The service counts them after it converts supported values and removes duplicates. For example, a claim of ["1", 1, 1.0] counts as one value.

For the numbers, see Record visibility configuration limits.

The request-time limit applies only to caller fields that the configuration references. A claim that the configuration tests only with ForAnyValue:StringEquals, ContainsAll, or Exists has no such limit. A principal tag is always one value, so it never reaches the limit. The limit applies to every referenced field, even in a statement whose principal tests don’t match the caller.

The following table shows the result of a discovery request for a referenced groups claim.

Referenced groups claim Result

Within the limit after duplicates are removed

The service evaluates the request.

Over the limit

The whole request fails with a ValidationException. The service doesn’t truncate the values or skip the statement.

Missing, or no supported value

The statement is inapplicable. The request doesn’t fail.

A referenced attribute over the distinct-values limit fails the request

A request in which a referenced caller attribute exceeds the distinct-values limit fails with a ValidationException. On the MCP endpoint, the tool result is an error with the same message. Some identity providers issue a claim with many values, such as a large groups claim. For such a claim, limit the values in the token, or reference a narrower claim. For recovery steps, see A caller attribute exceeds the distinct-values limit in the troubleshooting topic. For MCP tool errors, see Tool results and errors.