aws-cdk-lib.aws_applicationautoscaling.CronOptions

interface CronOptions

LanguageType name
.NETAmazon.CDK.AWS.ApplicationAutoScaling.CronOptions
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapplicationautoscaling#CronOptions
Javasoftware.amazon.awscdk.services.applicationautoscaling.CronOptions
Pythonaws_cdk.aws_applicationautoscaling.CronOptions
TypeScript (source)aws-cdk-lib » aws_applicationautoscaling » CronOptions

Options to configure a cron expression.

All fields are strings so you can use complex expressions. Absence of a field implies '*' or '?', whichever one is appropriate.

See also: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions

Example

declare const cluster: ecs.Cluster;
const loadBalancedFargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'Service', {
  cluster,
  memoryLimitMiB: 1024,
  desiredCount: 1,
  cpu: 512,
  taskImageOptions: {
    image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
  },
});

const scalableTarget = loadBalancedFargateService.service.autoScaleTaskCount({
  minCapacity: 5,
  maxCapacity: 20,
});

scalableTarget.scaleOnSchedule('DaytimeScaleDown', {
  schedule: appscaling.Schedule.cron({ hour: '8', minute: '0'}),
  minCapacity: 1,
});

scalableTarget.scaleOnSchedule('EveningRushScaleUp', {
  schedule: appscaling.Schedule.cron({ hour: '20', minute: '0'}),
  minCapacity: 10,
});

Properties

NameTypeDescription
day?stringThe day of the month to run this rule at.
hour?stringThe hour to run this rule at.
minute?stringThe minute to run this rule at.
month?stringThe month to run this rule at.
weekDay?stringThe day of the week to run this rule at.
year?stringThe year to run this rule at.

day?

Type: string (optional, default: Every day of the month)

The day of the month to run this rule at.


hour?

Type: string (optional, default: Every hour)

The hour to run this rule at.


minute?

Type: string (optional, default: Every minute)

The minute to run this rule at.


month?

Type: string (optional, default: Every month)

The month to run this rule at.


weekDay?

Type: string (optional, default: Any day of the week)

The day of the week to run this rule at.


year?

Type: string (optional, default: Every year)

The year to run this rule at.