Amazon Redshift (Scheduled queries)

0

Hello world! Is it possible to Enable or Disable Scheduled queries through aws cli (powershell) or python? I know about Query editor v2, but I need to automate this task.

1 Answer
0

Hello.

Redshift's scheduled queries are created behind the scenes by EventBridge.
In other words, I think you can enable and disable EventBridge using AWS CLI, etc.
https://docs.aws.amazon.com/redshift/latest/mgmt/query-editor-schedule-query.html

To create a schedule to run a SQL statement, you can use the query editor on the Amazon Redshift console. You can create a schedule to run your SQL statement at the time intervals that match your business needs. When it's time for the scheduled query to run, Amazon EventBridge initiates the query.

Use "disable-rule" to disable an event rule.
When enabling an event rule, you need to use "put-rule" and specify "--schedule-expression" as an option.
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/events/put-rule.html
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/events/disable-rule.html

aws events disable-rule --name test
aws events put-rule --name test --state ENABLED --schedule-expression "rate(1 hour)"
profile picture
EXPERT
answered 18 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions