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

Unable to set ScheduleExpression to at(some date) and delete rule after completion #4420

Closed
1 task
mgsotelo opened this issue Feb 1, 2025 · 3 comments
Closed
1 task
Assignees
Labels
bug This issue is a confirmed bug. cloudwatch p2 This is a standard priority issue response-requested Waiting on additional information or feedback.

Comments

@mgsotelo
Copy link

mgsotelo commented Feb 1, 2025

Describe the bug

Hi,

I am encountering an issue with the boto3 library where I am unable to set the ScheduleExpression to at(some date) using the put_rule method for CloudWatch Events. Additionally, I am unable to delete the rule after it has been triggered because the library does not accept the at ScheduleExpression.

Please let me know if there is a workaround for this issue or if there are any plans to support the at(some date) ScheduleExpression in the future.

Thank you!

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The put_rule method should accept the at(some date) ScheduleExpression and create the rule successfully.

Current Behavior

The put_rule method throws a ValidationException indicating that the ScheduleExpression is not valid.

Reproduction Steps

  1. Attempt to create a CloudWatch Events rule with a ScheduleExpression set to at(some date) using the put_rule method.
  2. Observe that the ScheduleExpression is not accepted and results in a ValidationException.

Code Example:

import boto3
from datetime import datetime, timedelta, timezone

# Initialize boto3 client, it may need credentials or something
events_client = boto3.client('events')

# Calculate the event launch time (1 hour from now) => the event should be sent to a lambda function (yay!) 
expected_time = datetime.now(timezone.utc) + timedelta(hours=1)
schedule_expression = f"at({expected_time.isoformat()})"

# Attempt to create the rule
try:
    response = events_client.put_rule(
        Name='awesome-event-instance-rule',
        ScheduleExpression=schedule_expression,
        State='ENABLED',
        Description='Do something awesome at a specific time'
    )
    print("Rule created:", response)
except Exception as e:
    print("Error creating rule:", str(e))

Possible Solution

IDK

Additional Information/Context

I also need to delete the rule after it has been triggered, but since the at ScheduleExpression is not accepted, I am unable to achieve this.

SDK version used

boto3==1.36.10

Environment details (OS name and version, etc.)

Python 3.11.5 // macOS Sonoma 14.2.1

@mgsotelo mgsotelo added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Feb 1, 2025
@RyanFitzSimmonsAK RyanFitzSimmonsAK self-assigned this Feb 3, 2025
@RyanFitzSimmonsAK RyanFitzSimmonsAK added investigating This issue is being investigated and/or work is in progress to resolve the issue. cloudwatch p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Feb 3, 2025
@RyanFitzSimmonsAK
Copy link
Contributor

Hi @mgsotelo, thanks for reaching out. It looks like PutRule does not support one-time schedules. Only cron and rate expressions are documented in https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-scheduled-rule-pattern.html. One-time schedules are supported by Scheduler CreateSchedule, and you can find info about that here. Let me know if you have any follow-up questions about that.

@RyanFitzSimmonsAK RyanFitzSimmonsAK added response-requested Waiting on additional information or feedback. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Feb 4, 2025
@mgsotelo
Copy link
Author

mgsotelo commented Feb 5, 2025

Hi @RyanFitzSimmonsAK, I was able to use CreateSchedule in my code. It seems that this is no longer an issue :D

@mgsotelo mgsotelo closed this as completed Feb 5, 2025
Copy link

github-actions bot commented Feb 5, 2025

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. cloudwatch p2 This is a standard priority issue response-requested Waiting on additional information or feedback.
Projects
None yet
Development

No branches or pull requests

2 participants