Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-events: Rule schedule property type checking failing Python #27258

Closed
danielwilton-metoffice opened this issue Sep 22, 2023 · 4 comments
Closed
Labels
@aws-cdk/aws-events Related to CloudWatch Events bug This issue is a bug. duplicate This issue is a duplicate.

Comments

@danielwilton-metoffice
Copy link

danielwilton-metoffice commented Sep 22, 2023

Describe the bug

Specifying aws_events.Schedule.rate(core.Duration.minutes(30)) for the schedule property on aws_events.Rule class, fails on aws-cdk-lib==2.97.0 at synth time.

This is also the same for the cron and expression properties.

type of argument schedule must be one of (aws_cdk.aws_events.Schedule, NoneType); got aws_cdk._ScheduleProxy instead

Expected Behavior

This was previously working to create an Event Rule:

lambda_event = aws_events.Rule(
    self,
    "LambdaEventName",
    description="Trigger x lambda",
    enabled=True,
    schedule=aws_events.Schedule.rate(core.Duration.minutes(30)),
    targets=[lambda_target],
)

Current Behavior

Error at synth time:

TypeError: type of argument schedule must be one of (aws_cdk.aws_events.Schedule, NoneType); got aws_cdk._ScheduleProxy instead.

Reproduction Steps

Install latest aws-cdk-lib in Python and create an aws_event.Rule object with the schedule property set to aws_events.Schedule.rate(core.Duration.minutes(30)), and run cdk synth.

Possible Solution

Workaround:

aws-cdk-lib==2.96.0

Additional Information/Context

No response

CDK CLI Version

2.96.2 (build 3edd240) and 2.97.0 (build d7cf3be)

Framework Version

2.97.0

Node.js Version

20.7.0

OS

Windows

Language

Python

Language Version

Python 3.9.17

Other information

With the Schedule functionality getting moved to core and the aws_events.Schedule now inheriting this version, I'm guessing there are some proxying issues with jsii?

@danielwilton-metoffice danielwilton-metoffice added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 22, 2023
@github-actions github-actions bot added the @aws-cdk/aws-events Related to CloudWatch Events label Sep 22, 2023
@danielwilton-metoffice
Copy link
Author

danielwilton-metoffice commented Sep 22, 2023

Linked issue: #27259

I believe this is because the new core.Schedule functionality is actually returning a core.LiteralSchedule that extends the core.Schedule class, which has protected members and isn't the matching consumer aws_events.Schedule with public members, causing issues when compiled with JSII.

@danielwilton-metoffice
Copy link
Author

danielwilton-metoffice commented Sep 23, 2023

Created a fork, and reverted rate to use a LiteralSchedule that inherits from the consumer Schedule abstract class and that does fix the issue:
9795d1b

However, this does mean that there will be more repeated code, that I understand the refactor was aiming to avoid. Struggling to think of a way around this otherwise currently as Parameterised Types can't be used with jsii.

U-lis added a commit to planetarium/NineChronicles.IAP that referenced this issue Sep 25, 2023
- Latest version of aws-cdk-lib casuses event schedule error
    - Downgrade 2.97 to 2.96
    - Reference: aws/aws-cdk#27258
@peterwoodworth peterwoodworth added duplicate This issue is a duplicate. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 25, 2023
@peterwoodworth
Copy link
Contributor

Thanks for the report @danielwilton-metoffice, I'm going to close this in favor of #27259 🙂

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-events Related to CloudWatch Events bug This issue is a bug. duplicate This issue is a duplicate.
Projects
None yet
Development

No branches or pull requests

2 participants