Skip to content

aws-autoscaling: Schedule.cron fails with "Cannot supply both 'day' and 'weekDay', use at most one" #27256

@lmiguelmh

Description

@lmiguelmh

Describe the bug

Using the Schedule.cron fails on aws-cdk-lib==2.97.0 at synth time.

Cannot supply both 'day' and 'weekDay', use at most one

This is how I was calling it before:

autoscaling.Schedule.cron(
      week_day="MON-SUN",
      hour="1",  # 01:00 UTC+0 ~ 20:00 int PET (-05:00)
      minute="0",
  )

The problem may be here:

const cron = super.protectedCron({
weekDay: '*', // to override core.Schedule's default
day: '*', // to override core.Schedule's default
...options,
});
const cronSplit = cron.expressionString.slice(5).split(' '); // remove "cron(" from start
cronSplit.pop(); // remove year, since autoscaling does not accept it
const autoscalingCron = cronSplit.join(' ');

Expected Behavior

This was working before:

autoscaling.Schedule.cron(
      week_day="MON-SUN",
      hour="1",  # 01:00 UTC+0 ~ 20:00 int PET (-05:00)
      minute="0",
  )

Current Behavior

Error at synth time:

RuntimeError: Error: Cannot supply both 'day' and 'weekDay', use at most one

Reproduction Steps

Install latest aws-cdk-lib

Possible Solution

Workaround:

aws-cdk-lib==2.96.0

Additional Information/Context

No response

CDK CLI Version

2.97.0 (build d7cf3be)

Framework Version

No response

Node.js Version

v20.5.1

OS

Linux

Language

Python

Language Version

Python 3.11.5

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-autoscalingRelated to Amazon EC2 Auto ScalingbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions