potiuk commented on code in PR #30864:
URL: https://github.com/apache/airflow/pull/30864#discussion_r1181094274


##########
airflow/providers/amazon/aws/triggers/redshift_cluster.py:
##########
@@ -137,3 +137,52 @@ async def run(self):
                 },
             )
         yield TriggerEvent({"status": "success", "message": "Cluster Created"})
+
+
+class RedshiftResumeClusterTrigger(BaseTrigger):
+    """
+    Trigger for RedshiftResumeClusterOperator.
+    The trigger will asynchronously poll the boto3 API and wait for the
+    Redshift cluster to be in the `available` state.
+
+    :param cluster_identifier:  A unique identifier for the cluster.
+    :param poll_interval: The amount of time in seconds to wait between 
attempts.
+    :param max_attempt: The maximum number of attempts to be made.
+    :param aws_conn_id: The Airflow connection used for AWS credentials.
+    """
+
+    def __init__(
+        self,
+        cluster_identifier: str,
+        poll_interval: int,
+        max_attempt: int,
+        aws_conn_id: str,
+    ):
+        self.cluster_identifier = cluster_identifier
+        self.poll_interval = poll_interval
+        self.max_attempt = max_attempt
+        self.aws_conn_id = aws_conn_id
+
+    def serialize(self) -> tuple[str, dict[str, Any]]:
+        return (
+            
"airflow.providers.amazon.aws.triggers.redshift_cluster.RedshiftResumeClusterTrigger",
+            {
+                "cluster_identifier": str(self.cluster_identifier),
+                "poll_interval": str(self.poll_interval),
+                "max_attempt": str(self.max_attempt),
+                "aws_conn_id": str(self.aws_conn_id),
+            },
+        )
+
+    async def run(self):
+        self.redshift_hook = RedshiftHook(aws_conn_id=self.aws_conn_id)
+        async with self.redshift_hook.async_conn as client:
+            waiter = self.redshift_hook.get_waiter("cluster_resumed", 
deferrable=True, client=client)
+            await waiter.wait(

Review Comment:
   Should we also think about the case where we want to log some events in 
trigger periodically while waiting ? similar to discussion in 
https://github.com/apache/airflow/pull/30853#issuecomment-1526764681 ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to