# ScheduleExpression

Schedule expression for CloudWatch alarm mute rule.

You can choose from three schedule types when configuring your schedule: cron-based and one-time schedules.
Cron-based schedule is recurring schedule.

Obtainable from: ScheduleExpression.at, ScheduleExpression.cron, ScheduleExpression.expression

- 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#L63)
- 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)
```

## Initializer

TypeScript:

```ts
new ScheduleExpression()
```

Python:

```python
ScheduleExpression()
```

Java:

```java
new ScheduleExpression()
```

C# / .NET:

```csharp
new ScheduleExpression()
```

Golang:

```go
NewScheduleExpression()
```

## Properties

- `expressionString`: string — Retrieve the expression for this schedule.

- `timeZone`: [TimeZone](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.TimeZone.html) — Retrieve the expression for this schedule.

## Methods

- `at(date: CalendarDateTime, timeZone?: TimeZone): ScheduleExpression // chainable` (static) — Construct a one-time schedule from a date.

  **Parameters**

  - `date` — The date and time to use.
  - `timeZone` — The time zone to use for interpreting the date.

- `cron(options: CronOptions): ScheduleExpression // chainable` (static) — Create a recurring schedule from a set of cron fields and time zone.

- `expression(expression: string, timeZone?: TimeZone): ScheduleExpression // chainable` (static) — Construct a schedule from a literal schedule expression.

  **Parameters**

  - `expression` — The expression to use.
  - `timeZone` — The time zone to use for interpreting the expression.
