You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/06/07 02:52:20 UTC

[GitHub] [airflow] josh-fell commented on a diff in pull request #24057: Amazon appflow

josh-fell commented on code in PR #24057:
URL: https://github.com/apache/airflow/pull/24057#discussion_r890700946


##########
airflow/providers/amazon/aws/hooks/appflow.py:
##########
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import TYPE_CHECKING
+
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.client import AppflowClient
+
+
+class AppflowHook(AwsBaseHook):
+    """
+    Interact with Amazon Appflow, using the boto3 library
+    Hook attribute `conn` has all methods that listed in documentation
+
+    .. seealso::
+        - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/appflow.html
+        - https://docs.aws.amazon.com/appflow/1.0/APIReference/Welcome.html
+
+    Additional arguments (such as ``aws_conn_id`` or ``region_name``) may be specified and
+        are passed down to the underlying AwsBaseHook.
+
+    .. seealso::
+        :class:`~airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+
+    :param aws_conn_id: The Airflow connection used for AWS credentials.

Review Comment:
   This isn't an explicit parameter for the hook and probably should be removed from the docstring so it's not present in the Python API documentation. WDYT?
   
   ```suggestion
   ```



##########
airflow/providers/amazon/aws/example_dags/example_appflow.py:
##########
@@ -0,0 +1,110 @@
+# Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   @vincbeck @ferruzzi @o-nikolas Should this DAG contain prep work for future AIP-47 conversion?



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")

Review Comment:
   ```suggestion
           self.log.info("Waiting for flow run...")
   ```
   Nit here as well.



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,

Review Comment:
   Can you add this param to the operator's docstring?



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunFullOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunBeforeOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only previous data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunBeforeOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunBeforeOperator!")
+        if source not in {"salesforce"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunBeforeOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "LESS_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunAfterOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only future data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunAfterOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunAfterOperator!")
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunAfterOperator!")

Review Comment:
   Same comment and suggestion as above.



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunFullOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunBeforeOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only previous data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunBeforeOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunBeforeOperator!")
+        if source not in {"salesforce"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunBeforeOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "LESS_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunAfterOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only future data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunAfterOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunAfterOperator!")
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunAfterOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "GREATER_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunDailyOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only a single day.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunDailyOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",

Review Comment:
   ```suggestion
           aws_conn_id: str = "aws_default",
   ```



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,

Review Comment:
   I think it would be beneficial to have a more verbose parameter name. I find it difficult to discern what this is and what it would apply to. Maybe something like `filter_date`?



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")

Review Comment:
   ```suggestion
               raise ValueError(f"{source!r} is not a supported source (options: {SUPPORTED_SOURCES})!")
   ```
   This exception seems more appropriate.



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).

Review Comment:
   WDYT about setting `__all__` in this module so this can't _actually_ be imported externally if the idea is you really don't want users using it?
   
   Although, I can easily be convinced to not inhibit using this if folks want to create their own operator subclassing this one too so I don't have a strong opinion on this.



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")

Review Comment:
   ```suggestion
           self.log.info("Waiting for Appflow eventual consistence...")
   ```
   Small grammar nit.



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",

Review Comment:
   ```suggestion
           aws_conn_id: str = "aws_default",
   ```



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")

Review Comment:
   ```suggestion
           if source not in SUPPORTED_SOURCES:
               raise ValueError(f"Source {source!r} is not supported for AppflowRunOperator!")
   ```
   Same comment as above re: the exception type.



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunFullOperator!")

Review Comment:
   Same comments re: using `SUPPORTED_SOURCES` and throwing a `ValueError` instead. WDYT?



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",

Review Comment:
   ```suggestion
           aws_conn_id: str = "aws_default",
   ```



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunFullOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunBeforeOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only previous data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunBeforeOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunBeforeOperator!")
+        if source not in {"salesforce"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunBeforeOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "LESS_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunAfterOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only future data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunAfterOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",

Review Comment:
   ```suggestion
           aws_conn_id: str = "aws_default",
   ```



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunFullOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunBeforeOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only previous data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunBeforeOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",

Review Comment:
   ```suggestion
           aws_conn_id: str = "aws_default",
   ```



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",

Review Comment:
   ```suggestion
           aws_conn_id: str = "aws_default",
   ```



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunFullOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunBeforeOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only previous data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunBeforeOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunBeforeOperator!")
+        if source not in {"salesforce"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunBeforeOperator!")

Review Comment:
   ```suggestion
           if source != "salesforce":
               raise ValueError(f"Source {source!r} is not supported for AppflowRunBeforeOperator!")
   ```
   Now that I think of it, perhaps it would be useful to add what sources are supported to the docstring in these operators. This would explicitly expose the information in the Python API documentation for users. WDYT?



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunFullOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunBeforeOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only previous data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunBeforeOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunBeforeOperator!")
+        if source not in {"salesforce"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunBeforeOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "LESS_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunAfterOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only future data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunAfterOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunAfterOperator!")
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunAfterOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "GREATER_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunDailyOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only a single day.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunDailyOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunDailyOperator!")
+        if source not in {"salesforce"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunDailyOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        start_dt = self.dt_parsed - timedelta(milliseconds=1)
+        end_dt = self.dt_parsed + timedelta(days=1)
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "BETWEEN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "LOWER_BOUND": str(datetime_to_epoch_ms(start_dt)),  # NOT inclusive
+                "UPPER_BOUND": str(datetime_to_epoch_ms(end_dt)),  # NOT inclusive
+            },
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRecordsShortCircuitOperator(ShortCircuitOperator):
+    """
+    Short-circuit in case of a empty Appflow's run.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRecordsShortCircuitOperator`
+
+    :param flow_name: The flow name
+    :param appflow_run_task_id: Run task ID from where this operator should extract the execution ID
+    :param ignore_downstream_trigger_rules: Ignore downstream trigger rules (Ignored for Airflow < 2.3)
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    LIGHT_BLUE = "#33ffec"
+    ui_color = LIGHT_BLUE
+
+    def __init__(
+        self,
+        *,
+        flow_name: str,
+        appflow_run_task_id: str,
+        ignore_downstream_trigger_rules: bool = True,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if get_airflow_version() >= (2, 3):
+            kwargs["ignore_downstream_trigger_rules"] = ignore_downstream_trigger_rules
+        else:
+            self.log.warning(
+                "Ignoring argument ignore_downstream_trigger_rules (%s) - Only supported for Airflow >= 2.3",
+                ignore_downstream_trigger_rules,
+            )
+        super().__init__(
+            python_callable=self._has_new_records_func,
+            op_kwargs={
+                "flow_name": flow_name,
+                "appflow_run_task_id": appflow_run_task_id,
+            },
+            **kwargs,
+        )
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+
+    @staticmethod
+    def _get_target_execution_id(
+        records: List["ExecutionRecordTypeDef"], execution_id: str
+    ) -> Optional["ExecutionRecordTypeDef"]:
+        for record in records:
+            if record.get("executionId") == execution_id:
+                return record
+        return None
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def _has_new_records_func(self, **kwargs) -> bool:
+        appflow_task_id = kwargs["appflow_run_task_id"]
+        self.log.info("appflow_task_id: ", appflow_task_id)

Review Comment:
   ```suggestion
           self.log.info("appflow_task_id: %s", appflow_task_id)
   ```



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunFullOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunBeforeOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only previous data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunBeforeOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunBeforeOperator!")
+        if source not in {"salesforce"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunBeforeOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "LESS_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunAfterOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only future data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunAfterOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunAfterOperator!")
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunAfterOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "GREATER_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunDailyOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only a single day.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunDailyOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunDailyOperator!")
+        if source not in {"salesforce"}:

Review Comment:
   ```suggestion
           if source != "salesforce":
   ```
   Also same suggestion as above instances too re: the exception type and message formatting. It might be worth creating a global variable for the exception message since it's repeated often.



##########
airflow/providers/amazon/aws/operators/appflow.py:
##########
@@ -0,0 +1,545 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import copy
+import json
+import sys
+from datetime import datetime, timedelta, timezone
+from time import sleep
+from typing import TYPE_CHECKING, List, Optional, cast
+
+if sys.version_info >= (3, 8):
+    from functools import cached_property
+else:
+    from cached_property import cached_property
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.operators.python import ShortCircuitOperator
+from airflow.providers.amazon.aws.hooks.appflow import AppflowHook
+from airflow.providers.amazon.aws.utils import datetime_to_epoch_ms, get_airflow_version
+
+if TYPE_CHECKING:
+    from mypy_boto3_appflow.type_defs import (
+        DescribeFlowExecutionRecordsResponseTypeDef,
+        DescribeFlowResponseTypeDef,
+        ExecutionRecordTypeDef,
+        TaskTypeDef,
+    )
+
+    from airflow.utils.context import Context
+
+EVENTUAL_CONSISTENCY_OFFSET: int = 15  # seconds
+EVENTUAL_CONSISTENCY_POLLING: int = 10  # seconds
+SUPPORTED_SOURCES = {"salesforce", "zendesk"}
+
+
+class AppflowBaseOperator(BaseOperator):
+    """
+    Amazon Appflow Base Operator class (not supposed to be used directly in DAGs).
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    BLUE = "#2bccbd"
+    ui_color = BLUE
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        flow_update: bool,
+        source_field: Optional[str] = None,
+        dt: Optional[str] = None,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        if source not in SUPPORTED_SOURCES:
+            raise AirflowException(f"{source} is not a supported source (options: {SUPPORTED_SOURCES})!")
+        self.dt = dt
+        self.name = name
+        self.source = source
+        self.source_field = source_field
+        self.poll_interval = poll_interval
+        self.aws_conn_id = aws_conn_id
+        self.region = region
+        self.flow_update = flow_update
+
+    @cached_property
+    def hook(self) -> AppflowHook:
+        """Create and return an AppflowHook."""
+        return AppflowHook(aws_conn_id=self.aws_conn_id, region_name=self.region)
+
+    def execute(self, context: "Context") -> None:
+        self.dt_parsed: Optional[datetime] = datetime.fromisoformat(self.dt) if self.dt else None
+        if self.flow_update:
+            self._update_flow()
+        self._run_flow(context)
+
+    def _get_connector_type(self, response: "DescribeFlowResponseTypeDef") -> str:
+        connector_type = response["sourceFlowConfig"]["connectorType"]
+        if self.source != connector_type.lower():
+            raise AirflowException(
+                f"Incompatible source ({self.source} and connector type ({connector_type})!"
+            )
+        return connector_type
+
+    def _update_flow(self) -> None:
+        response = self.hook.conn.describe_flow(flowName=self.name)
+        connector_type = self._get_connector_type(response)
+
+        # cleanup
+        tasks: List["TaskTypeDef"] = []
+        for task in response["tasks"]:
+            if (
+                task["taskType"] == "Filter"
+                and task.get("connectorOperator", {}).get(connector_type) != "PROJECTION"
+            ):
+                self.log.info("Removing task: %s", task)
+            else:
+                tasks.append(task)  # List of non-filter tasks
+
+        self._add_filter(connector_type, tasks)
+
+        # Clean up to force on-demand trigger
+        trigger_config = copy.deepcopy(response["triggerConfig"])
+        del trigger_config["triggerProperties"]
+
+        self.hook.conn.update_flow(
+            flowName=response["flowName"],
+            destinationFlowConfigList=response["destinationFlowConfigList"],
+            sourceFlowConfig=response["sourceFlowConfig"],
+            triggerConfig=trigger_config,
+            description=response.get("description", "Flow description."),
+            tasks=tasks,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:  # Interface
+        pass
+
+    def _run_flow(self, context) -> str:
+        ts_before: datetime = datetime.now(timezone.utc)
+        sleep(EVENTUAL_CONSISTENCY_OFFSET)
+        response = self.hook.conn.start_flow(flowName=self.name)
+        task_instance = context["task_instance"]
+        task_instance.xcom_push("execution_id", response["executionId"])
+        self.log.info("executionId: %s", response["executionId"])
+
+        response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait Appflow eventual consistence
+        self.log.info("Waiting Appflow eventual consistence...")
+        while (
+            response.get("lastRunExecutionDetails", {}).get(
+                "mostRecentExecutionTime", datetime(1970, 1, 1, tzinfo=timezone.utc)
+            )
+            < ts_before
+        ):
+            sleep(EVENTUAL_CONSISTENCY_POLLING)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        # Wait flow stops
+        self.log.info("Waiting flow run...")
+        while (
+            "mostRecentExecutionStatus" not in response["lastRunExecutionDetails"]
+            or response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "InProgress"
+        ):
+            sleep(self.poll_interval)
+            response = self.hook.conn.describe_flow(flowName=self.name)
+
+        self.log.info("lastRunExecutionDetails: %s", response["lastRunExecutionDetails"])
+
+        if response["lastRunExecutionDetails"]["mostRecentExecutionStatus"] == "Error":
+            raise Exception(f"Flow error:\n{json.dumps(response, default=str)}")
+
+        return response["lastRunExecutionDetails"]["mostRecentExecutionStatus"]
+
+
+class AppflowRunOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run with filters as is.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=False,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunFullOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow full run removing any filter.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunFullOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunFullOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=None,
+            dt=None,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+
+class AppflowRunBeforeOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only previous data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunBeforeOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunBeforeOperator!")
+        if source not in {"salesforce"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunBeforeOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "LESS_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunAfterOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only future data.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunAfterOperator`
+
+    :param source: The source name (e.g. salesforce, zendesk)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunAfterOperator!")
+        if source not in {"salesforce", "zendesk"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunAfterOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "GREATER_THAN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "VALUE": str(datetime_to_epoch_ms(self.dt_parsed)),
+            },  # NOT inclusive
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRunDailyOperator(AppflowBaseOperator):
+    """
+    Execute a Appflow run after updating the filters to select only a single day.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRunDailyOperator`
+
+    :param source: The source name (e.g. salesforce)
+    :param name: The flow name
+    :param source_field: The field name to apply filters
+    :param dt: The date value (or template) to be used in filters.
+    :param poll_interval: how often in seconds to check the query status
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    template_fields = ("dt",)
+
+    def __init__(
+        self,
+        source: str,
+        name: str,
+        source_field: str,
+        dt: str,
+        poll_interval: int = 20,
+        aws_conn_id: Optional[str] = "aws_default",
+        region: Optional[str] = None,
+        **kwargs,
+    ) -> None:
+        if not dt:
+            raise AirflowException("The dt argument is mandatory for AppflowRunDailyOperator!")
+        if source not in {"salesforce"}:
+            raise AirflowException(f"Source {source} is not supported for AppflowRunDailyOperator!")
+        super().__init__(
+            source=source,
+            name=name,
+            flow_update=True,
+            source_field=source_field,
+            dt=dt,
+            poll_interval=poll_interval,
+            aws_conn_id=aws_conn_id,
+            region=region,
+            **kwargs,
+        )
+
+    def _add_filter(self, connector_type: str, tasks: List["TaskTypeDef"]) -> None:
+        if not self.dt_parsed:
+            raise AirflowException(f"Invalid dt argument parser value: {self.dt_parsed}")
+        if not self.source_field:
+            raise AirflowException(f"Invalid source_field argument value: {self.source_field}")
+        start_dt = self.dt_parsed - timedelta(milliseconds=1)
+        end_dt = self.dt_parsed + timedelta(days=1)
+        filter_task: "TaskTypeDef" = {
+            "taskType": "Filter",
+            "connectorOperator": {connector_type: "BETWEEN"},  # type: ignore
+            "sourceFields": [self.source_field],
+            "taskProperties": {
+                "DATA_TYPE": "datetime",
+                "LOWER_BOUND": str(datetime_to_epoch_ms(start_dt)),  # NOT inclusive
+                "UPPER_BOUND": str(datetime_to_epoch_ms(end_dt)),  # NOT inclusive
+            },
+        }
+        tasks.append(filter_task)
+
+
+class AppflowRecordsShortCircuitOperator(ShortCircuitOperator):
+    """
+    Short-circuit in case of a empty Appflow's run.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:AppflowRecordsShortCircuitOperator`
+
+    :param flow_name: The flow name
+    :param appflow_run_task_id: Run task ID from where this operator should extract the execution ID
+    :param ignore_downstream_trigger_rules: Ignore downstream trigger rules (Ignored for Airflow < 2.3)
+    :param aws_conn_id: aws connection to use
+    :param region: aws region to use
+    """
+
+    LIGHT_BLUE = "#33ffec"
+    ui_color = LIGHT_BLUE
+
+    def __init__(
+        self,
+        *,
+        flow_name: str,
+        appflow_run_task_id: str,
+        ignore_downstream_trigger_rules: bool = True,
+        aws_conn_id: Optional[str] = "aws_default",

Review Comment:
   Same typing update as above.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org