# PolicyCondition

A condition on a policy statement.

A condition compares a request attribute against a value. Conditions are grouped
into the `when` and `unless` clauses of a statement, where the members of a clause
must all hold.

Comparisons are named for the type of value they accept, so each one takes a
concrete type rather than a union. Use `allOf` and `anyOf` to build a nested
boolean expression, which also makes the grouping explicit in the generated Cedar.

- Source: [`aws-bedrockagentcore/lib/policy/policy-statement.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/policy/policy-statement.ts#L202)
- Type last changed: v2.269.0 · 10 Sep 2026

## Example

```ts
import { PolicyAttribute, PolicyCondition } from 'aws-cdk-lib/aws-bedrockagentcore';

// principal.department == "Engineering"
PolicyCondition.stringEquals(PolicyAttribute.principal('department'), 'Engineering');

// (principal.department == "Engineering" || principal.department == "Support")
PolicyCondition.anyOf([
  PolicyCondition.stringEquals(PolicyAttribute.principal('department'), 'Engineering'),
  PolicyCondition.stringEquals(PolicyAttribute.principal('department'), 'Support'),
]);
```

## Methods

- `allOf(conditions: PolicyCondition[]): PolicyCondition // chainable` (static) — All of the given conditions must hold.

  Renders as a parenthesised `&&` group, so it can be nested inside `anyOf`
  without relying on operator precedence.

  **Parameters**

  - `conditions` — - The conditions to combine, at least one.

- `anyOf(conditions: PolicyCondition[]): PolicyCondition // chainable` (static) — At least one of the given conditions must hold.

  Renders as a parenthesised `||` group, so it can be nested inside `allOf` or
  combined with the surrounding clause without relying on operator precedence.

  **Parameters**

  - `conditions` — - The conditions to combine, at least one.

- `booleanEquals(attribute: PolicyAttribute, value: boolean): PolicyCondition // chainable` (static) — The attribute equals a boolean value.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `value` — - The value to compare against.

- `ipInRange(attribute: PolicyAttribute, cidr: string): PolicyCondition // chainable` (static) — The attribute is an IP address inside the given CIDR range.

  **Parameters**

  - `attribute` — - The attribute holding an IP address.
  - `cidr` — - The range in CIDR notation, for example '192.168.1.0/24'.

- `numberEquals(attribute: PolicyAttribute, value: number): PolicyCondition // chainable` (static) — The attribute equals a number value.

  Cedar whole numbers are 64-bit signed integers, so the value must be an integer.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `value` — - The value to compare against.

- `numberGreaterThan(attribute: PolicyAttribute, value: number): PolicyCondition // chainable` (static) — The attribute is greater than a number value.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `value` — - The value to compare against.

- `numberGreaterThanOrEquals(attribute: PolicyAttribute, value: number): PolicyCondition // chainable` (static) — The attribute is greater than or equal to a number value.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `value` — - The value to compare against.

- `numberIn(attribute: PolicyAttribute, values: number[]): PolicyCondition // chainable` (static) — The attribute is one of the given number values.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `values` — - The allowed values, at least one.

- `numberLessThan(attribute: PolicyAttribute, value: number): PolicyCondition // chainable` (static) — The attribute is less than a number value.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `value` — - The value to compare against.

- `numberLessThanOrEquals(attribute: PolicyAttribute, value: number): PolicyCondition // chainable` (static) — The attribute is less than or equal to a number value.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `value` — - The value to compare against.

- `numberNotEquals(attribute: PolicyAttribute, value: number): PolicyCondition // chainable` (static) — The attribute does not equal a number value.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `value` — - The value to compare against.

- `setContains(attribute: PolicyAttribute, value: string): PolicyCondition // chainable` (static) — The attribute is a set that contains the given value.

  Use this when the attribute itself holds a set, for example `principal.groups`.
  To test a scalar attribute against a list of allowed values, use `stringIn` or
  `numberIn` instead.

  **Parameters**

  - `attribute` — - The attribute holding a set.
  - `value` — - The member to look for.

- `stringEquals(attribute: PolicyAttribute, value: string): PolicyCondition // chainable` (static) — The attribute equals a string value.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `value` — - The value to compare against.

- `stringIn(attribute: PolicyAttribute, values: string[]): PolicyCondition // chainable` (static) — The attribute is one of the given string values.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `values` — - The allowed values, at least one.

- `stringNotEquals(attribute: PolicyAttribute, value: string): PolicyCondition // chainable` (static) — The attribute does not equal a string value.

  **Parameters**

  - `attribute` — - The attribute to compare.
  - `value` — - The value to compare against.
