# ConditionBuilder

Builder for condition expressions in Cedar policies.

Conditions define when a policy statement should apply or not apply.
Supports logical operators (AND, OR) and various comparison operators.

Used as argument in: [AttributeAccessor (initializer)](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.AttributeAccessor.html#initializer), ConditionalAttributeAccessor (initializer), ConditionalPolicyStatement (initializer)
Returned by: [AttributeAccessor.contains](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.AttributeAccessor.html#contains), [AttributeAccessor.equalTo](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.AttributeAccessor.html#equalto), AttributeAccessor.greaterThan, AttributeAccessor.greaterThanOrEqualTo, AttributeAccessor.isIn, AttributeAccessor.isInRange, AttributeAccessor.lessThan, AttributeAccessor.lessThanOrEqualTo, AttributeAccessor.notEqualTo, ConditionBuilder.and, ConditionBuilder.or

- Source: [`lib/policy/policy-statement.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/policy/policy-statement.ts#L142)
- Type last changed: v2.278.0-alpha.0 · 21 Nov 2026

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as bedrock_agentcore_alpha from '@aws-cdk/aws-bedrock-agentcore-alpha';
const conditionBuilder = new bedrock_agentcore_alpha.ConditionBuilder();
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_bedrock_agentcore_alpha as bedrock_agentcore_alpha

condition_builder = bedrock_agentcore_alpha.ConditionBuilder()
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.bedrock.agentcore.alpha.*;

ConditionBuilder conditionBuilder = new ConditionBuilder();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Agentcore.Alpha
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Bedrock.Agentcore.Alpha;

var conditionBuilder = new ConditionBuilder();
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import bedrock_agentcore_alpha "github.com/aws/aws-cdk-go/awsbedrockagentcorealpha"

conditionBuilder := bedrock_agentcore_alpha.NewConditionBuilder()
```

## Initializer

TypeScript:

```ts
new ConditionBuilder()
```

Python:

```python
ConditionBuilder()
```

Java:

```java
new ConditionBuilder()
```

C# / .NET:

```csharp
new ConditionBuilder()
```

Golang:

```go
NewConditionBuilder()
```

## Methods

- `and(): ConditionBuilder // chainable` — Logical AND operator - all conditions must be true.

- `contextAttribute(attribute: string): AttributeAccessor` — Access a context attribute for comparison.

  Context attributes come from the request environment.
  Common attributes: sourceIp, timestamp, environment, region, etc.

  **Parameters**

  - `attribute` — - The attribute name (e.g., 'sourceIp', 'environment', 'timestamp').

- `or(): ConditionBuilder // chainable` — Logical OR operator - at least one condition must be true.

- `principalAttribute(attribute: string): AttributeAccessor` — Access a principal attribute for comparison.

  Principal attributes come from the authenticated user/service making the request.
  Common attributes: username, role, department, groups, etc.

  **Parameters**

  - `attribute` — - The attribute name (e.g., 'department', 'role', 'username').

- `resourceAttribute(attribute: string): AttributeAccessor` — Access a resource attribute for comparison.

  Resource attributes come from the target resource being accessed.
  Common attributes: arn, type, tags, owner, etc.

  **Parameters**

  - `attribute` — - The attribute name (e.g., 'confidential', 'owner', 'classification').
