# CronOptions

Options to configure a cron expression.

All fields are strings so you can use complex expressions.
Absence of a field implies '*'.

Used as argument in: [ScheduleExpression.cron](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.ScheduleExpression.html#cron)

- Source: [`aws-cloudwatch/lib/alarm-mute-rule.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudwatch/lib/alarm-mute-rule.ts#L123)
- Type last changed: v2.264.0 · 10 Aug 2026

## Example

TypeScript:

```ts
declare const alarm1: cloudwatch.Alarm;
declare const alarm2: cloudwatch.Alarm;

const alarmMuteRule = new cloudwatch.AlarmMuteRule(this, 'AlarmMuteRule', {
  alarms: [alarm1],
  // Defines the mute period begins at 0:00 everyday in UTC
  schedule: cloudwatch.ScheduleExpression.cron({ minute: '0', hour: '0' }),
  // Specifies the mute rule lasts 1 hour.
  duration: Duration.hours(1),
})

// The mute target can be added after construction.
alarmMuteRule.addAlarm(alarm2);
```

Python:

```python
# alarm1: cloudwatch.Alarm
# alarm2: cloudwatch.Alarm

alarm_mute_rule = cloudwatch.AlarmMuteRule(self, "AlarmMuteRule",
    alarms=[alarm1],
    # Defines the mute period begins at 0:00 everyday in UTC
    schedule=cloudwatch.ScheduleExpression.cron(minute="0", hour="0"),
    # Specifies the mute rule lasts 1 hour.
    duration=Duration.hours(1)
)

# The mute target can be added after construction.
alarm_mute_rule.add_alarm(alarm2)
```

Java:

```java
Alarm alarm1;
Alarm alarm2;

AlarmMuteRule alarmMuteRule = AlarmMuteRule.Builder.create(this, "AlarmMuteRule")
        .alarms(List.of(alarm1))
        // Defines the mute period begins at 0:00 everyday in UTC
        .schedule(ScheduleExpression.cron(CronOptions.builder().minute("0").hour("0").build()))
        // Specifies the mute rule lasts 1 hour.
        .duration(Duration.hours(1))
        .build();

// The mute target can be added after construction.
alarmMuteRule.addAlarm(alarm2);
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Alarm alarm1;
Alarm alarm2;

var alarmMuteRule = new AlarmMuteRule(this, "AlarmMuteRule", new AlarmMuteRuleProps {
    Alarms = new [] { alarm1 },
    // Defines the mute period begins at 0:00 everyday in UTC
    Schedule = ScheduleExpression.Cron(new CronOptions { Minute = "0", Hour = "0" }),
    // Specifies the mute rule lasts 1 hour.
    Duration = Duration.Hours(1)
});

// The mute target can be added after construction.
alarmMuteRule.AddAlarm(alarm2);
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var alarm1 Alarm
var alarm2 Alarm

alarmMuteRule := cloudwatch.NewAlarmMuteRule(this, jsii.String("AlarmMuteRule"), &AlarmMuteRuleProps{
	Alarms: []IAlarmRef{
		alarm1,
	},
	// Defines the mute period begins at 0:00 everyday in UTC
	Schedule: cloudwatch.ScheduleExpression_Cron(&CronOptions{
		Minute: jsii.String("0"),
		Hour: jsii.String("0"),
	}),
	// Specifies the mute rule lasts 1 hour.
	Duration: awscdk.Duration_Hours(jsii.Number(1)),
})

// The mute target can be added after construction.
alarmMuteRule.AddAlarm(alarm2)
```

## Properties

- `day`: string — The day of the month to run this rule at.

  **Default:** Every day of the month

- `hour`: string — The hour to run this rule at.

  **Default:** Every hour

- `minute`: string (required) — The minute to run this rule at.

- `month`: string — The month to run this rule at.

  **Default:** Every month

- `timeZone`: [TimeZone](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.TimeZone.html) = TimeZone.ETC_UTC — The timezone to run the schedule in.

- `weekDay`: string — The day of the week to run this rule at.

  **Default:** Any day of the week
