# ComparisonOperator

Comparison operator for evaluating alarms.

- Source: [`aws-cloudwatch/lib/alarm.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudwatch/lib/alarm.ts#L73)

## Example

TypeScript:

```ts
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';

declare const myHostedZone: route53.HostedZone;
const certificate = new acm.Certificate(this, 'Certificate', {
  domainName: 'hello.example.com',
  validation: acm.CertificateValidation.fromDns(myHostedZone),
});
certificate.metricDaysToExpiry().createAlarm(this, 'Alarm', {
  comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD,
  evaluationPeriods: 1,
  threshold: 45, // Automatic rotation happens between 60 and 45 days before expiry
});
```

Python:

```python
import aws_cdk.aws_cloudwatch as cloudwatch

# my_hosted_zone: route53.HostedZone

certificate = acm.Certificate(self, "Certificate",
    domain_name="hello.example.com",
    validation=acm.CertificateValidation.from_dns(my_hosted_zone)
)
certificate.metric_days_to_expiry().create_alarm(self, "Alarm",
    comparison_operator=cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD,
    evaluation_periods=1,
    threshold=45
)
```

Java:

```java
import software.amazon.awscdk.services.cloudwatch.*;

HostedZone myHostedZone;

Certificate certificate = Certificate.Builder.create(this, "Certificate")
        .domainName("hello.example.com")
        .validation(CertificateValidation.fromDns(myHostedZone))
        .build();
certificate.metricDaysToExpiry().createAlarm(this, "Alarm", CreateAlarmOptions.builder()
        .comparisonOperator(ComparisonOperator.LESS_THAN_THRESHOLD)
        .evaluationPeriods(1)
        .threshold(45)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.CloudWatch;

HostedZone myHostedZone;

var certificate = new Certificate(this, "Certificate", new CertificateProps {
    DomainName = "hello.example.com",
    Validation = CertificateValidation.FromDns(myHostedZone)
});
certificate.MetricDaysToExpiry().CreateAlarm(this, "Alarm", new CreateAlarmOptions {
    ComparisonOperator = ComparisonOperator.LESS_THAN_THRESHOLD,
    EvaluationPeriods = 1,
    Threshold = 45
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import cloudwatch "github.com/aws/aws-cdk-go/awscdk"

var myHostedZone HostedZone

certificate := acm.NewCertificate(this, jsii.String("Certificate"), &CertificateProps{
	DomainName: jsii.String("hello.example.com"),
	Validation: acm.CertificateValidation_FromDns(myHostedZone),
})
certificate.metricDaysToExpiry().CreateAlarm(this, jsii.String("Alarm"), &CreateAlarmOptions{
	ComparisonOperator: cloudwatch.ComparisonOperator_LESS_THAN_THRESHOLD,
	EvaluationPeriods: jsii.Number(1),
	Threshold: jsii.Number(45),
})
```

## Members

| Member | Description |
| --- | --- |
| `GREATER_THAN_OR_EQUAL_TO_THRESHOLD` | Specified statistic is greater than or equal to the threshold. |
| `GREATER_THAN_THRESHOLD` | Specified statistic is strictly greater than the threshold. |
| `LESS_THAN_THRESHOLD` | Specified statistic is strictly less than the threshold. |
| `LESS_THAN_OR_EQUAL_TO_THRESHOLD` | Specified statistic is less than or equal to the threshold. |
| `LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD` | Specified statistic is lower than or greater than the anomaly model band. |
| `GREATER_THAN_UPPER_THRESHOLD` | Specified statistic is greater than the anomaly model band. |
| `LESS_THAN_LOWER_THRESHOLD` | Specified statistic is lower than the anomaly model band. |

## Referenced by

- [`AnomalyDetectionAlarmProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.AnomalyDetectionAlarmProps.html).comparisonOperator
- [`CreateAlarmOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.CreateAlarmOptions.html).comparisonOperator
