Skip to content
v2.277.0

ScheduleExpression Class ​

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.

Example ​

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
# 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
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);
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);
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 ​

ts
new ScheduleExpression()
python
ScheduleExpression()
java
new ScheduleExpression()
csharp
new ScheduleExpression()
go
NewScheduleExpression()

Properties ​

expressionStringstringexpression_stringstrexpressionStringStringExpressionStringstringExpressionString*string#
Retrieve the expression for this schedule.
timeZonemay be undefinedTimeZonetime_zonemay be undefinedTimeZonetimeZonemay be undefinedTimeZoneTimeZonemay be undefinedTimeZoneTimeZonemay be undefinedTimeZone#
Retrieve the expression for this schedule.

Methods ​

at(date: CalendarDateTime, timeZone?: TimeZone): ScheduleExpression // chainable@staticmethod def at(date: CalendarDateTime, time_zone: typing.Optional[TimeZone] = None) -> ScheduleExpressionpublic static ScheduleExpression at(CalendarDateTime date, TimeZone timeZone)public static ScheduleExpression At(CalendarDateTime date, TimeZone? timeZone = null)func At(Date CalendarDateTime, TimeZone TimeZone) ScheduleExpressionstatic#
Construct a one-time schedule from a date.
2 parameters

Parameters

  • datedatedatedateDate — The date and time to use.
  • timeZonetime_zonetimeZonetimeZoneTimeZone — The time zone to use for interpreting the date.
cron(options: CronOptions): ScheduleExpression // chainable@staticmethod def cron(options: CronOptions) -> ScheduleExpressionpublic static ScheduleExpression cron(CronOptions options)public static ScheduleExpression Cron(CronOptions options)func Cron(Options CronOptions) ScheduleExpressionstatic#
Create a recurring schedule from a set of cron fields and time zone.
expression(expression: string, timeZone?: TimeZone): ScheduleExpression // chainable@staticmethod def expression(expression: str, time_zone: typing.Optional[TimeZone] = None) -> ScheduleExpressionpublic static ScheduleExpression expression(String expression, TimeZone timeZone)public static ScheduleExpression Expression(string expression, TimeZone? timeZone = null)func Expression(Expression *string, TimeZone TimeZone) ScheduleExpressionstatic#
Construct a schedule from a literal schedule expression.
2 parameters

Parameters

  • expressionexpressionexpressionexpressionExpression — The expression to use.
  • timeZonetime_zonetimeZonetimeZoneTimeZone — The time zone to use for interpreting the expression.