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

Open
1 task
mgsotelo opened this issue Feb 1, 2025 · 0 comments
Open
1 task
Labels
bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged.

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
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. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant