CronOptions

class aws_cdk.aws_applicationautoscaling.CronOptions(*, day=None, hour=None, minute=None, month=None, week_day=None, year=None)

Bases: object

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.

Parameters
  • day (Optional[str]) – The day of the month to run this rule at. Default: - Every day of the month

  • hour (Optional[str]) – The hour to run this rule at. Default: - Every hour

  • minute (Optional[str]) – The minute to run this rule at. Default: - Every minute

  • month (Optional[str]) – The month to run this rule at. Default: - Every month

  • week_day (Optional[str]) – The day of the week to run this rule at. Default: - Any day of the week

  • year (Optional[str]) – The year to run this rule at. Default: - Every year

See

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

ExampleMetadata

infused

Example:

# cluster: ecs.Cluster

load_balanced_fargate_service = ecs_patterns.ApplicationLoadBalancedFargateService(self, "Service",
    cluster=cluster,
    memory_limit_mi_b=1024,
    desired_count=1,
    cpu=512,
    task_image_options=ecsPatterns.ApplicationLoadBalancedTaskImageOptions(
        image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample")
    )
)

scalable_target = load_balanced_fargate_service.service.auto_scale_task_count(
    min_capacity=5,
    max_capacity=20
)

scalable_target.scale_on_schedule("DaytimeScaleDown",
    schedule=appscaling.Schedule.cron(hour="8", minute="0"),
    min_capacity=1
)

scalable_target.scale_on_schedule("EveningRushScaleUp",
    schedule=appscaling.Schedule.cron(hour="20", minute="0"),
    min_capacity=10
)

Attributes

day

The day of the month to run this rule at.

Default
  • Every day of the month

Return type

Optional[str]

hour

The hour to run this rule at.

Default
  • Every hour

Return type

Optional[str]

minute

The minute to run this rule at.

Default
  • Every minute

Return type

Optional[str]

month

The month to run this rule at.

Default
  • Every month

Return type

Optional[str]

week_day

The day of the week to run this rule at.

Default
  • Any day of the week

Return type

Optional[str]

year

The year to run this rule at.

Default
  • Every year

Return type

Optional[str]