# Condition

Class · Stable

A condition that determines when a conditional trigger fires.

A condition watches exactly one target in exactly one state: use
{@link Condition.job} to watch a job or {@link Condition.crawler} to watch a
crawler. Because the state is a required argument of each factory, a condition
can never reference a target without its state, or both a job and a crawler.

Obtainable from: Condition.crawler, Condition.job

- Source: [`aws-glue/lib/triggers/trigger-options.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-glue/lib/triggers/trigger-options.ts#L219)
- Type last changed: v2.270.0 · 17 Sep 2026

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_glue as glue } from 'aws-cdk-lib';
import { aws_glue as interfaces_glue } from 'aws-cdk-lib/interfaces';

declare const crawlerRef: interfaces_glue.ICrawlerRef;
const condition = glue.Condition.crawler(crawlerRef, glue.CrawlerState.RUNNING, /* all optional props */ {
  logicalOperator: glue.ConditionLogicalOperator.EQUALS,
});
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_glue as glue
from aws_cdk.interfaces import aws_glue as interfaces_glue

# crawler_ref: interfaces_glue.ICrawlerRef

condition = glue.Condition.crawler(crawler_ref, glue.CrawlerState.RUNNING,
    logical_operator=glue.ConditionLogicalOperator.EQUALS
)
```

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.glue.*;
import software.amazon.awscdk.interfaces.glue.*;

ICrawlerRef crawlerRef;

Condition condition = Condition.crawler(crawlerRef, CrawlerState.RUNNING, ConditionOptions.builder()
        .logicalOperator(ConditionLogicalOperator.EQUALS)
        .build());
```

C#:

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

ICrawlerRef crawlerRef;

var condition = Condition.Crawler(crawlerRef, CrawlerState.RUNNING, new ConditionOptions {
    LogicalOperator = ConditionLogicalOperator.EQUALS
});
```

Go:

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

var crawlerRef ICrawlerRef

condition := awscdk.Aws_glue.Condition_Crawler(crawlerRef, awscdk.Aws_glue.CrawlerState_RUNNING, &ConditionOptions{
	LogicalOperator: awscdk.*Aws_glue.ConditionLogicalOperator_EQUALS,
})
```

## Initializer

TypeScript:

```ts
new Condition()
```

Python:

```python
Condition()
```

Java:

```java
new Condition()
```

C#:

```csharp
new Condition()
```

Go:

```go
NewCondition()
```

## Methods

- `crawler(crawler: ICrawlerRef, crawlState: CrawlerState, options?: ConditionOptions): Condition // chainable` (static) — Create a condition on the state of a crawler.

  **Parameters**

  - `crawler` — the crawler to watch.
  - `crawlState` — the crawler state that satisfies the condition.
  - `options` — additional options for the condition.

- `job(job: IJobRef, state: JobState, options?: ConditionOptions): Condition // chainable` (static) — Create a condition on the state of a job.

  **Parameters**

  - `job` — the job to watch.
  - `state` — the job state that satisfies the condition.
  - `options` — additional options for the condition.
