# Condition

The condition for the stage.

A condition is made up of the rules and the result for the condition.

- Source: [`aws-codepipeline/lib/pipeline.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-codepipeline/lib/pipeline.ts#L80)
- Type last changed: v2.186.0 · 27 Mar 2025

## Example

TypeScript:

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

declare const rule: codepipeline.Rule;
const condition: codepipeline.Condition = {
  result: codepipeline.Result.ROLLBACK,
  rules: [rule],
};
```

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_codepipeline as codepipeline

# rule: codepipeline.Rule

condition = codepipeline.Condition(
    result=codepipeline.Result.ROLLBACK,
    rules=[rule]
)
```

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.codepipeline.*;

Rule rule;

Condition condition = Condition.builder()
        .result(Result.ROLLBACK)
        .rules(List.of(rule))
        .build();
```

C# / .NET:

```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.CodePipeline;

Rule rule;

var condition = new Condition {
    Result = Result.ROLLBACK,
    Rules = new [] { rule }
};
```

Golang:

```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"

var rule Rule

condition := &Condition{
	Result: awscdk.Aws_codepipeline.Result_ROLLBACK,
	Rules: []Rule{
		rule,
	},
}
```

## Properties

- `result`: [Result](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline.Result.html) — The action to be done when the condition is met.

  **Default:** No result action is taken

- `rules`: [Rule](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline.Rule.html)[] — The rules that make up the condition.

  **Default:** No rules are applied
