pankajastro commented on code in PR #30244:
URL: https://github.com/apache/airflow/pull/30244#discussion_r1209487638


##########
airflow/providers/amazon/aws/triggers/redshift_cluster.py:
##########
@@ -357,3 +357,79 @@ async def run(self):
             )
         else:
             yield TriggerEvent({"status": "success", "message": "Cluster 
resumed"})
+
+
+class RedshiftDeleteClusterTrigger(BaseTrigger):
+    """
+    Trigger for RedshiftDeleteClusterOperator
+
+    :param cluster_identifier:  A unique identifier for the cluster.
+    :param max_attempts: The maximum number of attempts to be made.
+    :param aws_conn_id: The Airflow connection used for AWS credentials.
+    :param poll_interval: The amount of time in seconds to wait between 
attempts.
+    """
+
+    def __init__(
+        self,
+        cluster_identifier: str,
+        max_attempts: int = 30,
+        aws_conn_id: str = "aws_default",
+        poll_interval: int = 30,
+    ):
+        super().__init__()
+        self.cluster_identifier = cluster_identifier
+        self.max_attempts = max_attempts
+        self.aws_conn_id = aws_conn_id
+        self.poll_interval = poll_interval
+
+    def serialize(self) -> tuple[str, dict[str, Any]]:
+        return (
+            
"airflow.providers.amazon.aws.triggers.redshift_cluster.RedshiftDeleteClusterTrigger",
+            {
+                "cluster_identifier": self.cluster_identifier,
+                "max_attempts": self.max_attempts,
+                "aws_conn_id": self.aws_conn_id,
+                "poll_interval": self.poll_interval,
+            },
+        )
+
+    @cached_property
+    def hook(self):
+        return RedshiftHook(aws_conn_id=self.aws_conn_id)
+
+    async def run(self) -> AsyncIterator[TriggerEvent]:
+        async with self.hook.async_conn as client:
+            attempt = 0
+            waiter = client.get_waiter("cluster_deleted")
+            while attempt < self.max_attempts:
+                attempt = attempt + 1
+                try:
+                    self.log.info("attempt=%s max_attempts=%s", attempt, 
self.max_attempts)

Review Comment:
   ```suggestion
   ```



-- 
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