apache-airflow-providers-amazon 9.15.0__py3-none-any.whl → 9.18.1rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. airflow/providers/amazon/__init__.py +3 -3
  2. airflow/providers/amazon/aws/auth_manager/avp/facade.py +1 -1
  3. airflow/providers/amazon/aws/auth_manager/routes/login.py +7 -1
  4. airflow/providers/amazon/aws/bundles/s3.py +1 -1
  5. airflow/providers/amazon/aws/exceptions.py +1 -1
  6. airflow/providers/amazon/aws/executors/aws_lambda/docker/app.py +5 -1
  7. airflow/providers/amazon/aws/executors/aws_lambda/lambda_executor.py +1 -2
  8. airflow/providers/amazon/aws/executors/batch/batch_executor.py +1 -2
  9. airflow/providers/amazon/aws/executors/ecs/ecs_executor.py +1 -2
  10. airflow/providers/amazon/aws/hooks/athena.py +7 -3
  11. airflow/providers/amazon/aws/hooks/athena_sql.py +3 -3
  12. airflow/providers/amazon/aws/hooks/base_aws.py +3 -7
  13. airflow/providers/amazon/aws/hooks/batch_client.py +5 -7
  14. airflow/providers/amazon/aws/hooks/batch_waiters.py +1 -2
  15. airflow/providers/amazon/aws/hooks/chime.py +2 -2
  16. airflow/providers/amazon/aws/hooks/comprehend.py +1 -1
  17. airflow/providers/amazon/aws/hooks/datasync.py +3 -3
  18. airflow/providers/amazon/aws/hooks/dynamodb.py +1 -1
  19. airflow/providers/amazon/aws/hooks/ec2.py +1 -1
  20. airflow/providers/amazon/aws/hooks/elasticache_replication_group.py +1 -1
  21. airflow/providers/amazon/aws/hooks/emr.py +1 -1
  22. airflow/providers/amazon/aws/hooks/firehose.py +56 -0
  23. airflow/providers/amazon/aws/hooks/glue.py +9 -2
  24. airflow/providers/amazon/aws/hooks/glue_catalog.py +1 -1
  25. airflow/providers/amazon/aws/hooks/kinesis.py +31 -13
  26. airflow/providers/amazon/aws/hooks/logs.py +10 -2
  27. airflow/providers/amazon/aws/hooks/mwaa.py +38 -7
  28. airflow/providers/amazon/aws/hooks/quicksight.py +1 -1
  29. airflow/providers/amazon/aws/hooks/rds.py +1 -1
  30. airflow/providers/amazon/aws/hooks/redshift_sql.py +31 -8
  31. airflow/providers/amazon/aws/hooks/s3.py +14 -6
  32. airflow/providers/amazon/aws/hooks/sagemaker.py +1 -1
  33. airflow/providers/amazon/aws/hooks/sagemaker_unified_studio.py +1 -2
  34. airflow/providers/amazon/aws/hooks/ssm.py +34 -6
  35. airflow/providers/amazon/aws/hooks/step_function.py +1 -1
  36. airflow/providers/amazon/aws/links/base_aws.py +1 -1
  37. airflow/providers/amazon/aws/links/emr.py +1 -1
  38. airflow/providers/amazon/aws/log/cloudwatch_task_handler.py +50 -20
  39. airflow/providers/amazon/aws/operators/appflow.py +1 -1
  40. airflow/providers/amazon/aws/operators/athena.py +1 -1
  41. airflow/providers/amazon/aws/operators/base_aws.py +2 -2
  42. airflow/providers/amazon/aws/operators/batch.py +1 -1
  43. airflow/providers/amazon/aws/operators/bedrock.py +3 -1
  44. airflow/providers/amazon/aws/operators/cloud_formation.py +2 -2
  45. airflow/providers/amazon/aws/operators/comprehend.py +1 -1
  46. airflow/providers/amazon/aws/operators/datasync.py +1 -1
  47. airflow/providers/amazon/aws/operators/dms.py +1 -1
  48. airflow/providers/amazon/aws/operators/ec2.py +1 -1
  49. airflow/providers/amazon/aws/operators/ecs.py +1 -1
  50. airflow/providers/amazon/aws/operators/eks.py +2 -1
  51. airflow/providers/amazon/aws/operators/emr.py +22 -12
  52. airflow/providers/amazon/aws/operators/eventbridge.py +1 -1
  53. airflow/providers/amazon/aws/operators/glue.py +1 -1
  54. airflow/providers/amazon/aws/operators/glue_crawler.py +1 -1
  55. airflow/providers/amazon/aws/operators/glue_databrew.py +1 -1
  56. airflow/providers/amazon/aws/operators/kinesis_analytics.py +1 -1
  57. airflow/providers/amazon/aws/operators/lambda_function.py +1 -1
  58. airflow/providers/amazon/aws/operators/mwaa.py +13 -4
  59. airflow/providers/amazon/aws/operators/neptune.py +1 -1
  60. airflow/providers/amazon/aws/operators/rds.py +1 -1
  61. airflow/providers/amazon/aws/operators/redshift_cluster.py +1 -1
  62. airflow/providers/amazon/aws/operators/redshift_data.py +1 -1
  63. airflow/providers/amazon/aws/operators/s3.py +1 -1
  64. airflow/providers/amazon/aws/operators/sagemaker.py +1 -1
  65. airflow/providers/amazon/aws/operators/sagemaker_unified_studio.py +1 -2
  66. airflow/providers/amazon/aws/operators/ssm.py +122 -17
  67. airflow/providers/amazon/aws/operators/step_function.py +1 -1
  68. airflow/providers/amazon/aws/secrets/secrets_manager.py +3 -4
  69. airflow/providers/amazon/aws/sensors/athena.py +1 -1
  70. airflow/providers/amazon/aws/sensors/base_aws.py +2 -2
  71. airflow/providers/amazon/aws/sensors/batch.py +1 -1
  72. airflow/providers/amazon/aws/sensors/bedrock.py +1 -1
  73. airflow/providers/amazon/aws/sensors/comprehend.py +1 -1
  74. airflow/providers/amazon/aws/sensors/dms.py +1 -1
  75. airflow/providers/amazon/aws/sensors/ec2.py +1 -1
  76. airflow/providers/amazon/aws/sensors/ecs.py +1 -1
  77. airflow/providers/amazon/aws/sensors/eks.py +2 -1
  78. airflow/providers/amazon/aws/sensors/emr.py +1 -3
  79. airflow/providers/amazon/aws/sensors/glacier.py +1 -1
  80. airflow/providers/amazon/aws/sensors/glue.py +1 -1
  81. airflow/providers/amazon/aws/sensors/glue_catalog_partition.py +1 -1
  82. airflow/providers/amazon/aws/sensors/glue_crawler.py +1 -1
  83. airflow/providers/amazon/aws/sensors/kinesis_analytics.py +1 -1
  84. airflow/providers/amazon/aws/sensors/lambda_function.py +1 -1
  85. airflow/providers/amazon/aws/sensors/mwaa.py +15 -2
  86. airflow/providers/amazon/aws/sensors/opensearch_serverless.py +1 -1
  87. airflow/providers/amazon/aws/sensors/quicksight.py +1 -1
  88. airflow/providers/amazon/aws/sensors/rds.py +1 -1
  89. airflow/providers/amazon/aws/sensors/redshift_cluster.py +1 -1
  90. airflow/providers/amazon/aws/sensors/s3.py +3 -3
  91. airflow/providers/amazon/aws/sensors/sagemaker.py +1 -1
  92. airflow/providers/amazon/aws/sensors/sagemaker_unified_studio.py +1 -2
  93. airflow/providers/amazon/aws/sensors/sqs.py +1 -1
  94. airflow/providers/amazon/aws/sensors/ssm.py +33 -17
  95. airflow/providers/amazon/aws/sensors/step_function.py +1 -1
  96. airflow/providers/amazon/aws/transfers/azure_blob_to_s3.py +3 -3
  97. airflow/providers/amazon/aws/transfers/base.py +5 -5
  98. airflow/providers/amazon/aws/transfers/dynamodb_to_s3.py +4 -4
  99. airflow/providers/amazon/aws/transfers/exasol_to_s3.py +1 -1
  100. airflow/providers/amazon/aws/transfers/ftp_to_s3.py +1 -1
  101. airflow/providers/amazon/aws/transfers/gcs_to_s3.py +48 -6
  102. airflow/providers/amazon/aws/transfers/glacier_to_gcs.py +1 -1
  103. airflow/providers/amazon/aws/transfers/google_api_to_s3.py +2 -5
  104. airflow/providers/amazon/aws/transfers/hive_to_dynamodb.py +1 -1
  105. airflow/providers/amazon/aws/transfers/http_to_s3.py +1 -1
  106. airflow/providers/amazon/aws/transfers/imap_attachment_to_s3.py +1 -1
  107. airflow/providers/amazon/aws/transfers/local_to_s3.py +1 -1
  108. airflow/providers/amazon/aws/transfers/mongo_to_s3.py +1 -1
  109. airflow/providers/amazon/aws/transfers/redshift_to_s3.py +6 -7
  110. airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py +1 -2
  111. airflow/providers/amazon/aws/transfers/s3_to_ftp.py +1 -1
  112. airflow/providers/amazon/aws/transfers/s3_to_redshift.py +6 -7
  113. airflow/providers/amazon/aws/transfers/s3_to_sftp.py +1 -1
  114. airflow/providers/amazon/aws/transfers/s3_to_sql.py +1 -2
  115. airflow/providers/amazon/aws/transfers/salesforce_to_s3.py +1 -1
  116. airflow/providers/amazon/aws/transfers/sftp_to_s3.py +1 -1
  117. airflow/providers/amazon/aws/transfers/sql_to_s3.py +8 -9
  118. airflow/providers/amazon/aws/triggers/bedrock.py +1 -1
  119. airflow/providers/amazon/aws/triggers/ecs.py +1 -1
  120. airflow/providers/amazon/aws/triggers/eks.py +1 -1
  121. airflow/providers/amazon/aws/triggers/s3.py +29 -2
  122. airflow/providers/amazon/aws/triggers/sagemaker.py +1 -1
  123. airflow/providers/amazon/aws/triggers/sqs.py +1 -1
  124. airflow/providers/amazon/aws/triggers/ssm.py +17 -1
  125. airflow/providers/amazon/aws/utils/__init__.py +1 -1
  126. airflow/providers/amazon/aws/utils/connection_wrapper.py +3 -6
  127. airflow/providers/amazon/aws/utils/mixins.py +1 -1
  128. airflow/providers/amazon/aws/utils/waiter.py +3 -3
  129. airflow/providers/amazon/aws/utils/waiter_with_logging.py +1 -1
  130. airflow/providers/amazon/aws/waiters/emr.json +6 -6
  131. airflow/providers/amazon/get_provider_info.py +19 -1
  132. airflow/providers/amazon/version_compat.py +19 -16
  133. {apache_airflow_providers_amazon-9.15.0.dist-info → apache_airflow_providers_amazon-9.18.1rc1.dist-info}/METADATA +29 -19
  134. {apache_airflow_providers_amazon-9.15.0.dist-info → apache_airflow_providers_amazon-9.18.1rc1.dist-info}/RECORD +138 -136
  135. apache_airflow_providers_amazon-9.18.1rc1.dist-info/licenses/NOTICE +5 -0
  136. {apache_airflow_providers_amazon-9.15.0.dist-info → apache_airflow_providers_amazon-9.18.1rc1.dist-info}/WHEEL +0 -0
  137. {apache_airflow_providers_amazon-9.15.0.dist-info → apache_airflow_providers_amazon-9.18.1rc1.dist-info}/entry_points.txt +0 -0
  138. {airflow/providers/amazon → apache_airflow_providers_amazon-9.18.1rc1.dist-info/licenses}/LICENSE +0 -0
@@ -20,7 +20,6 @@ from __future__ import annotations
20
20
  from collections.abc import Sequence
21
21
  from typing import TYPE_CHECKING, Any
22
22
 
23
- from airflow.exceptions import AirflowException
24
23
  from airflow.providers.amazon.aws.hooks.ec2 import EC2Hook
25
24
  from airflow.providers.amazon.aws.links.ec2 import (
26
25
  EC2InstanceDashboardLink,
@@ -28,6 +27,7 @@ from airflow.providers.amazon.aws.links.ec2 import (
28
27
  )
29
28
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
30
29
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
30
+ from airflow.providers.common.compat.sdk import AirflowException
31
31
 
32
32
  if TYPE_CHECKING:
33
33
  from airflow.utils.context import Context
@@ -25,7 +25,6 @@ from time import sleep
25
25
  from typing import TYPE_CHECKING, Any
26
26
 
27
27
  from airflow.configuration import conf
28
- from airflow.exceptions import AirflowException
29
28
  from airflow.providers.amazon.aws.exceptions import EcsOperatorError, EcsTaskFailToStart
30
29
  from airflow.providers.amazon.aws.hooks.ecs import EcsClusterStates, EcsHook
31
30
  from airflow.providers.amazon.aws.hooks.logs import AwsLogsHook
@@ -39,6 +38,7 @@ from airflow.providers.amazon.aws.utils import validate_execute_complete_event
39
38
  from airflow.providers.amazon.aws.utils.identifiers import generate_uuid
40
39
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
41
40
  from airflow.providers.amazon.aws.utils.task_log_fetcher import AwsTaskLogFetcher
41
+ from airflow.providers.common.compat.sdk import AirflowException
42
42
  from airflow.utils.helpers import prune_dict
43
43
 
44
44
  if TYPE_CHECKING:
@@ -28,7 +28,7 @@ from typing import TYPE_CHECKING, Any, cast
28
28
  from botocore.exceptions import ClientError, WaiterError
29
29
 
30
30
  from airflow.configuration import conf
31
- from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
31
+ from airflow.exceptions import AirflowProviderDeprecationWarning
32
32
  from airflow.providers.amazon.aws.hooks.eks import EksHook
33
33
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
34
34
  from airflow.providers.amazon.aws.triggers.eks import (
@@ -43,6 +43,7 @@ from airflow.providers.amazon.aws.utils import validate_execute_complete_event
43
43
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
44
44
  from airflow.providers.amazon.aws.utils.waiter_with_logging import wait
45
45
  from airflow.providers.cncf.kubernetes.utils.pod_manager import OnFinishAction
46
+ from airflow.providers.common.compat.sdk import AirflowException
46
47
 
47
48
  try:
48
49
  from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
@@ -25,7 +25,7 @@ from typing import TYPE_CHECKING, Any
25
25
  from uuid import uuid4
26
26
 
27
27
  from airflow.configuration import conf
28
- from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
28
+ from airflow.exceptions import AirflowProviderDeprecationWarning
29
29
  from airflow.providers.amazon.aws.hooks.emr import EmrContainerHook, EmrHook, EmrServerlessHook
30
30
  from airflow.providers.amazon.aws.links.emr import (
31
31
  EmrClusterLink,
@@ -57,8 +57,9 @@ from airflow.providers.amazon.aws.utils.waiter import (
57
57
  waiter,
58
58
  )
59
59
  from airflow.providers.amazon.aws.utils.waiter_with_logging import wait
60
+ from airflow.providers.amazon.version_compat import NOTSET, ArgNotSet
61
+ from airflow.providers.common.compat.sdk import AirflowException
60
62
  from airflow.utils.helpers import exactly_one, prune_dict
61
- from airflow.utils.types import NOTSET, ArgNotSet
62
63
 
63
64
  if TYPE_CHECKING:
64
65
  from airflow.utils.context import Context
@@ -654,11 +655,10 @@ class EmrCreateJobFlowOperator(AwsBaseOperator[EmrHook]):
654
655
  :param region_name: AWS region_name. If not specified then the default boto3 behaviour is used.
655
656
  :param verify: Whether or not to verify SSL certificates. See:
656
657
  https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html
657
- :param wait_for_completion: Deprecated - use `wait_policy` instead.
658
- Whether to finish task immediately after creation (False) or wait for jobflow
658
+ :param wait_for_completion: Whether to finish task immediately after creation (False) or wait for jobflow
659
659
  completion (True)
660
660
  (default: None)
661
- :param wait_policy: Whether to finish the task immediately after creation (None) or:
661
+ :param wait_policy: Deprecated. Use `wait_for_completion` instead. Whether to finish the task immediately after creation (None) or:
662
662
  - wait for the jobflow completion (WaitPolicy.WAIT_FOR_COMPLETION)
663
663
  - wait for the jobflow completion and cluster to terminate (WaitPolicy.WAIT_FOR_STEPS_COMPLETION)
664
664
  (default: None)
@@ -698,19 +698,29 @@ class EmrCreateJobFlowOperator(AwsBaseOperator[EmrHook]):
698
698
  super().__init__(**kwargs)
699
699
  self.emr_conn_id = emr_conn_id
700
700
  self.job_flow_overrides = job_flow_overrides or {}
701
- self.wait_policy = wait_policy
701
+ self.wait_for_completion = wait_for_completion
702
702
  self.waiter_max_attempts = waiter_max_attempts or 60
703
703
  self.waiter_delay = waiter_delay or 60
704
704
  self.deferrable = deferrable
705
705
 
706
- if wait_for_completion is not None:
706
+ if wait_policy is not None:
707
707
  warnings.warn(
708
- "`wait_for_completion` parameter is deprecated, please use `wait_policy` instead.",
708
+ "`wait_policy` parameter is deprecated and will be removed in a future release; "
709
+ "please use `wait_for_completion` (bool) instead.",
709
710
  AirflowProviderDeprecationWarning,
710
711
  stacklevel=2,
711
712
  )
712
- # preserve previous behaviour
713
- self.wait_policy = WaitPolicy.WAIT_FOR_COMPLETION if wait_for_completion else None
713
+
714
+ if wait_for_completion is not None:
715
+ raise ValueError(
716
+ "Cannot specify both `wait_for_completion` and deprecated `wait_policy`. "
717
+ "Please use `wait_for_completion` (bool)."
718
+ )
719
+
720
+ self.wait_for_completion = wait_policy in (
721
+ WaitPolicy.WAIT_FOR_COMPLETION,
722
+ WaitPolicy.WAIT_FOR_STEPS_COMPLETION,
723
+ )
714
724
 
715
725
  @property
716
726
  def _hook_parameters(self):
@@ -748,8 +758,8 @@ class EmrCreateJobFlowOperator(AwsBaseOperator[EmrHook]):
748
758
  job_flow_id=self._job_flow_id,
749
759
  log_uri=get_log_uri(emr_client=self.hook.conn, job_flow_id=self._job_flow_id),
750
760
  )
751
- if self.wait_policy:
752
- waiter_name = WAITER_POLICY_NAME_MAPPING[self.wait_policy]
761
+ if self.wait_for_completion:
762
+ waiter_name = WAITER_POLICY_NAME_MAPPING[WaitPolicy.WAIT_FOR_COMPLETION]
753
763
 
754
764
  if self.deferrable:
755
765
  self.defer(
@@ -19,10 +19,10 @@ from __future__ import annotations
19
19
  from collections.abc import Sequence
20
20
  from typing import TYPE_CHECKING
21
21
 
22
- from airflow.exceptions import AirflowException
23
22
  from airflow.providers.amazon.aws.hooks.eventbridge import EventBridgeHook
24
23
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
25
24
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
25
+ from airflow.providers.common.compat.sdk import AirflowException
26
26
  from airflow.utils.helpers import prune_dict
27
27
 
28
28
  if TYPE_CHECKING:
@@ -25,7 +25,6 @@ from typing import TYPE_CHECKING, Any
25
25
  from botocore.exceptions import ClientError
26
26
 
27
27
  from airflow.configuration import conf
28
- from airflow.exceptions import AirflowException
29
28
  from airflow.providers.amazon.aws.hooks.glue import GlueDataQualityHook, GlueJobHook
30
29
  from airflow.providers.amazon.aws.hooks.s3 import S3Hook
31
30
  from airflow.providers.amazon.aws.links.glue import GlueJobRunDetailsLink
@@ -37,6 +36,7 @@ from airflow.providers.amazon.aws.triggers.glue import (
37
36
  )
38
37
  from airflow.providers.amazon.aws.utils import validate_execute_complete_event
39
38
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
39
+ from airflow.providers.common.compat.sdk import AirflowException
40
40
 
41
41
  if TYPE_CHECKING:
42
42
  from airflow.utils.context import Context
@@ -21,11 +21,11 @@ from collections.abc import Sequence
21
21
  from typing import TYPE_CHECKING, Any
22
22
 
23
23
  from airflow.configuration import conf
24
- from airflow.exceptions import AirflowException
25
24
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
26
25
  from airflow.providers.amazon.aws.triggers.glue_crawler import GlueCrawlerCompleteTrigger
27
26
  from airflow.providers.amazon.aws.utils import validate_execute_complete_event
28
27
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
28
+ from airflow.providers.common.compat.sdk import AirflowException
29
29
 
30
30
  if TYPE_CHECKING:
31
31
  from airflow.utils.context import Context
@@ -21,12 +21,12 @@ from collections.abc import Sequence
21
21
  from typing import TYPE_CHECKING, Any
22
22
 
23
23
  from airflow.configuration import conf
24
- from airflow.exceptions import AirflowException
25
24
  from airflow.providers.amazon.aws.hooks.glue_databrew import GlueDataBrewHook
26
25
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
27
26
  from airflow.providers.amazon.aws.triggers.glue_databrew import GlueDataBrewJobCompleteTrigger
28
27
  from airflow.providers.amazon.aws.utils import validate_execute_complete_event
29
28
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
29
+ from airflow.providers.common.compat.sdk import AirflowException
30
30
 
31
31
  if TYPE_CHECKING:
32
32
  from airflow.utils.context import Context
@@ -22,7 +22,6 @@ from typing import TYPE_CHECKING, Any, ClassVar
22
22
  from botocore.exceptions import ClientError
23
23
 
24
24
  from airflow.configuration import conf
25
- from airflow.exceptions import AirflowException
26
25
  from airflow.providers.amazon.aws.hooks.kinesis_analytics import KinesisAnalyticsV2Hook
27
26
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
28
27
  from airflow.providers.amazon.aws.triggers.kinesis_analytics import (
@@ -30,6 +29,7 @@ from airflow.providers.amazon.aws.triggers.kinesis_analytics import (
30
29
  )
31
30
  from airflow.providers.amazon.aws.utils import validate_execute_complete_event
32
31
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
32
+ from airflow.providers.common.compat.sdk import AirflowException
33
33
 
34
34
  if TYPE_CHECKING:
35
35
  from airflow.utils.context import Context
@@ -23,12 +23,12 @@ from datetime import timedelta
23
23
  from typing import TYPE_CHECKING, Any
24
24
 
25
25
  from airflow.configuration import conf
26
- from airflow.exceptions import AirflowException
27
26
  from airflow.providers.amazon.aws.hooks.lambda_function import LambdaHook
28
27
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
29
28
  from airflow.providers.amazon.aws.triggers.lambda_function import LambdaCreateFunctionCompleteTrigger
30
29
  from airflow.providers.amazon.aws.utils import validate_execute_complete_event
31
30
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
31
+ from airflow.providers.common.compat.sdk import AirflowException
32
32
 
33
33
  if TYPE_CHECKING:
34
34
  from airflow.utils.context import Context
@@ -19,15 +19,15 @@
19
19
  from __future__ import annotations
20
20
 
21
21
  from collections.abc import Sequence
22
- from typing import TYPE_CHECKING, Any
22
+ from typing import TYPE_CHECKING, Any, Literal
23
23
 
24
24
  from airflow.configuration import conf
25
- from airflow.exceptions import AirflowException
26
25
  from airflow.providers.amazon.aws.hooks.mwaa import MwaaHook
27
26
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
28
27
  from airflow.providers.amazon.aws.triggers.mwaa import MwaaDagRunCompletedTrigger
29
28
  from airflow.providers.amazon.aws.utils import validate_execute_complete_event
30
29
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
30
+ from airflow.providers.common.compat.sdk import AirflowException
31
31
 
32
32
  if TYPE_CHECKING:
33
33
  from airflow.utils.context import Context
@@ -46,12 +46,14 @@ class MwaaTriggerDagRunOperator(AwsBaseOperator[MwaaHook]):
46
46
  :param trigger_run_id: The Run ID. This together with trigger_dag_id are a unique key. (templated)
47
47
  :param logical_date: The logical date (previously called execution date). This is the time or interval
48
48
  covered by this DAG run, according to the DAG definition. This together with trigger_dag_id are a
49
- unique key. (templated)
49
+ unique key. This field is required if your environment is running with Airflow 3. (templated)
50
50
  :param data_interval_start: The beginning of the interval the DAG run covers
51
51
  :param data_interval_end: The end of the interval the DAG run covers
52
52
  :param conf: Additional configuration parameters. The value of this field can be set only when creating
53
53
  the object. (templated)
54
54
  :param note: Contains manually entered notes by the user about the DagRun. (templated)
55
+ :param airflow_version: The Airflow major version the MWAA environment runs.
56
+ This parameter is only used if the local web token method is used to call Airflow API. (templated)
55
57
 
56
58
  :param wait_for_completion: Whether to wait for DAG run to stop. (default: False)
57
59
  :param waiter_delay: Time in seconds to wait between status checks. (default: 120)
@@ -81,6 +83,7 @@ class MwaaTriggerDagRunOperator(AwsBaseOperator[MwaaHook]):
81
83
  "data_interval_end",
82
84
  "conf",
83
85
  "note",
86
+ "airflow_version",
84
87
  )
85
88
  template_fields_renderers = {"conf": "json"}
86
89
 
@@ -95,6 +98,7 @@ class MwaaTriggerDagRunOperator(AwsBaseOperator[MwaaHook]):
95
98
  data_interval_end: str | None = None,
96
99
  conf: dict | None = None,
97
100
  note: str | None = None,
101
+ airflow_version: Literal[2, 3] | None = None,
98
102
  wait_for_completion: bool = False,
99
103
  waiter_delay: int = 60,
100
104
  waiter_max_attempts: int = 20,
@@ -110,6 +114,7 @@ class MwaaTriggerDagRunOperator(AwsBaseOperator[MwaaHook]):
110
114
  self.data_interval_end = data_interval_end
111
115
  self.conf = conf if conf else {}
112
116
  self.note = note
117
+ self.airflow_version = airflow_version
113
118
  self.wait_for_completion = wait_for_completion
114
119
  self.waiter_delay = waiter_delay
115
120
  self.waiter_max_attempts = waiter_max_attempts
@@ -123,7 +128,10 @@ class MwaaTriggerDagRunOperator(AwsBaseOperator[MwaaHook]):
123
128
  dag_run_id = validated_event["dag_run_id"]
124
129
  self.log.info("DAG run %s of DAG %s completed", dag_run_id, self.trigger_dag_id)
125
130
  return self.hook.invoke_rest_api(
126
- env_name=self.env_name, path=f"/dags/{self.trigger_dag_id}/dagRuns/{dag_run_id}", method="GET"
131
+ env_name=self.env_name,
132
+ path=f"/dags/{self.trigger_dag_id}/dagRuns/{dag_run_id}",
133
+ method="GET",
134
+ airflow_version=self.airflow_version,
127
135
  )
128
136
 
129
137
  def execute(self, context: Context) -> dict:
@@ -146,6 +154,7 @@ class MwaaTriggerDagRunOperator(AwsBaseOperator[MwaaHook]):
146
154
  "conf": self.conf,
147
155
  "note": self.note,
148
156
  },
157
+ airflow_version=self.airflow_version,
149
158
  )
150
159
 
151
160
  dag_run_id = response["RestApiResponse"]["dag_run_id"]
@@ -23,7 +23,6 @@ from typing import TYPE_CHECKING, Any
23
23
  from botocore.exceptions import ClientError
24
24
 
25
25
  from airflow.configuration import conf
26
- from airflow.exceptions import AirflowException
27
26
  from airflow.providers.amazon.aws.hooks.neptune import NeptuneHook
28
27
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
29
28
  from airflow.providers.amazon.aws.triggers.neptune import (
@@ -32,6 +31,7 @@ from airflow.providers.amazon.aws.triggers.neptune import (
32
31
  NeptuneClusterStoppedTrigger,
33
32
  )
34
33
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
34
+ from airflow.providers.common.compat.sdk import AirflowException
35
35
 
36
36
  if TYPE_CHECKING:
37
37
  from airflow.utils.context import Context
@@ -23,7 +23,6 @@ from datetime import timedelta
23
23
  from typing import TYPE_CHECKING, Any
24
24
 
25
25
  from airflow.configuration import conf
26
- from airflow.exceptions import AirflowException
27
26
  from airflow.providers.amazon.aws.hooks.rds import RdsHook
28
27
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
29
28
  from airflow.providers.amazon.aws.triggers.rds import (
@@ -36,6 +35,7 @@ from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
36
35
  from airflow.providers.amazon.aws.utils.rds import RdsDbType
37
36
  from airflow.providers.amazon.aws.utils.tags import format_tags
38
37
  from airflow.providers.amazon.aws.utils.waiter_with_logging import wait
38
+ from airflow.providers.common.compat.sdk import AirflowException
39
39
  from airflow.utils.helpers import prune_dict
40
40
 
41
41
  if TYPE_CHECKING:
@@ -22,7 +22,6 @@ from datetime import timedelta
22
22
  from typing import TYPE_CHECKING, Any
23
23
 
24
24
  from airflow.configuration import conf
25
- from airflow.exceptions import AirflowException
26
25
  from airflow.providers.amazon.aws.hooks.redshift_cluster import RedshiftHook
27
26
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
28
27
  from airflow.providers.amazon.aws.triggers.redshift_cluster import (
@@ -34,6 +33,7 @@ from airflow.providers.amazon.aws.triggers.redshift_cluster import (
34
33
  )
35
34
  from airflow.providers.amazon.aws.utils import validate_execute_complete_event
36
35
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
36
+ from airflow.providers.common.compat.sdk import AirflowException
37
37
  from airflow.utils.helpers import prune_dict
38
38
 
39
39
  if TYPE_CHECKING:
@@ -20,12 +20,12 @@ from __future__ import annotations
20
20
  from typing import TYPE_CHECKING, Any
21
21
 
22
22
  from airflow.configuration import conf
23
- from airflow.exceptions import AirflowException
24
23
  from airflow.providers.amazon.aws.hooks.redshift_data import RedshiftDataHook
25
24
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
26
25
  from airflow.providers.amazon.aws.triggers.redshift_data import RedshiftDataTrigger
27
26
  from airflow.providers.amazon.aws.utils import validate_execute_complete_event
28
27
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
28
+ from airflow.providers.common.compat.sdk import AirflowException
29
29
 
30
30
  if TYPE_CHECKING:
31
31
  from mypy_boto3_redshift_data.type_defs import (
@@ -28,10 +28,10 @@ from typing import TYPE_CHECKING
28
28
  import pytz
29
29
  from dateutil import parser
30
30
 
31
- from airflow.exceptions import AirflowException
32
31
  from airflow.providers.amazon.aws.hooks.s3 import S3Hook
33
32
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
34
33
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
34
+ from airflow.providers.common.compat.sdk import AirflowException
35
35
  from airflow.utils.helpers import exactly_one
36
36
 
37
37
  if TYPE_CHECKING:
@@ -26,7 +26,6 @@ from typing import TYPE_CHECKING, Any, ClassVar
26
26
  from botocore.exceptions import ClientError
27
27
 
28
28
  from airflow.configuration import conf
29
- from airflow.exceptions import AirflowException
30
29
  from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
31
30
  from airflow.providers.amazon.aws.hooks.sagemaker import (
32
31
  LogState,
@@ -43,6 +42,7 @@ from airflow.providers.amazon.aws.utils import trim_none_values, validate_execut
43
42
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
44
43
  from airflow.providers.amazon.aws.utils.sagemaker import ApprovalStatus
45
44
  from airflow.providers.amazon.aws.utils.tags import format_tags
45
+ from airflow.providers.common.compat.sdk import AirflowException
46
46
  from airflow.utils.helpers import prune_dict
47
47
 
48
48
  if TYPE_CHECKING:
@@ -23,7 +23,6 @@ from functools import cached_property
23
23
  from typing import TYPE_CHECKING
24
24
 
25
25
  from airflow.configuration import conf
26
- from airflow.exceptions import AirflowException
27
26
  from airflow.providers.amazon.aws.hooks.sagemaker_unified_studio import (
28
27
  SageMakerNotebookHook,
29
28
  )
@@ -33,7 +32,7 @@ from airflow.providers.amazon.aws.links.sagemaker_unified_studio import (
33
32
  from airflow.providers.amazon.aws.triggers.sagemaker_unified_studio import (
34
33
  SageMakerNotebookJobTrigger,
35
34
  )
36
- from airflow.providers.amazon.version_compat import BaseOperator
35
+ from airflow.providers.common.compat.sdk import AirflowException, BaseOperator
37
36
 
38
37
  if TYPE_CHECKING:
39
38
  from airflow.utils.context import Context
@@ -20,7 +20,6 @@ from collections.abc import Sequence
20
20
  from typing import TYPE_CHECKING, Any
21
21
 
22
22
  from airflow.configuration import conf
23
- from airflow.exceptions import AirflowException
24
23
  from airflow.providers.amazon.aws.hooks.ssm import SsmHook
25
24
  from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
26
25
  from airflow.providers.amazon.aws.triggers.ssm import SsmRunCommandTrigger
@@ -36,27 +35,35 @@ class SsmRunCommandOperator(AwsBaseOperator[SsmHook]):
36
35
  Executes the SSM Run Command to perform actions on managed instances.
37
36
 
38
37
  .. seealso::
39
- For more information on how to use this operator, take a look at the guide:
38
+ For more information on how to use this operator, take a look at the
39
+ guide:
40
40
  :ref:`howto/operator:SsmRunCommandOperator`
41
41
 
42
- :param document_name: The name of the Amazon Web Services Systems Manager document (SSM document) to run.
43
- :param run_command_kwargs: Optional parameters to pass to the send_command API.
44
-
45
- :param wait_for_completion: Whether to wait for cluster to stop. (default: True)
46
- :param waiter_delay: Time in seconds to wait between status checks. (default: 120)
47
- :param waiter_max_attempts: Maximum number of attempts to check for job completion. (default: 75)
48
- :param deferrable: If True, the operator will wait asynchronously for the cluster to stop.
49
- This implies waiting for completion. This mode requires aiobotocore module to be installed.
50
- (default: False)
42
+ :param document_name: The name of the Amazon Web Services Systems Manager
43
+ document (SSM document) to run.
44
+ :param run_command_kwargs: Optional parameters to pass to the send_command
45
+ API.
46
+
47
+ :param wait_for_completion: Whether to wait for cluster to stop.
48
+ (default: True)
49
+ :param waiter_delay: Time in seconds to wait between status checks.
50
+ (default: 120)
51
+ :param waiter_max_attempts: Maximum number of attempts to check for job
52
+ completion. (default: 75)
53
+ :param deferrable: If True, the operator will wait asynchronously for the
54
+ cluster to stop. This implies waiting for completion. This mode
55
+ requires aiobotocore module to be installed. (default: False)
51
56
  :param aws_conn_id: The Airflow connection used for AWS credentials.
52
- If this is ``None`` or empty then the default boto3 behaviour is used. If
53
- running Airflow in a distributed manner and aws_conn_id is None or
57
+ If this is ``None`` or empty then the default boto3 behaviour is used.
58
+ If running Airflow in a distributed manner and aws_conn_id is None or
54
59
  empty, then default boto3 configuration would be used (and must be
55
60
  maintained on each worker node).
56
- :param region_name: AWS region_name. If not specified then the default boto3 behaviour is used.
61
+ :param region_name: AWS region_name. If not specified then the default
62
+ boto3 behaviour is used.
57
63
  :param verify: Whether or not to verify SSL certificates. See:
58
64
  https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html
59
- :param botocore_config: Configuration dictionary (key-values) for botocore client. See:
65
+ :param botocore_config: Configuration dictionary (key-values) for botocore
66
+ client. See:
60
67
  https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html
61
68
  """
62
69
 
@@ -90,7 +97,7 @@ class SsmRunCommandOperator(AwsBaseOperator[SsmHook]):
90
97
  event = validate_execute_complete_event(event)
91
98
 
92
99
  if event["status"] != "success":
93
- raise AirflowException(f"Error while running run command: {event}")
100
+ raise RuntimeError(f"Error while running run command: {event}")
94
101
 
95
102
  self.log.info("SSM run command `%s` completed.", event["command_id"])
96
103
  return event["command_id"]
@@ -112,6 +119,9 @@ class SsmRunCommandOperator(AwsBaseOperator[SsmHook]):
112
119
  waiter_delay=self.waiter_delay,
113
120
  waiter_max_attempts=self.waiter_max_attempts,
114
121
  aws_conn_id=self.aws_conn_id,
122
+ region_name=self.region_name,
123
+ verify=self.verify,
124
+ botocore_config=self.botocore_config,
115
125
  ),
116
126
  method_name="execute_complete",
117
127
  )
@@ -125,7 +135,102 @@ class SsmRunCommandOperator(AwsBaseOperator[SsmHook]):
125
135
  waiter.wait(
126
136
  CommandId=command_id,
127
137
  InstanceId=instance_id,
128
- WaiterConfig={"Delay": self.waiter_delay, "MaxAttempts": self.waiter_max_attempts},
138
+ WaiterConfig={
139
+ "Delay": self.waiter_delay,
140
+ "MaxAttempts": self.waiter_max_attempts,
141
+ },
129
142
  )
130
143
 
131
144
  return command_id
145
+
146
+
147
+ class SsmGetCommandInvocationOperator(AwsBaseOperator[SsmHook]):
148
+ """
149
+ Retrieves the output and execution details of an SSM command invocation.
150
+
151
+ This operator allows you to fetch the standard output, standard error,
152
+ execution status, and other details from SSM commands. It can be used to
153
+ retrieve output from commands executed by SsmRunCommandOperator in previous
154
+ tasks, or from commands executed outside of Airflow entirely.
155
+
156
+ The operator returns structured data including stdout, stderr, execution
157
+ times, and status information for each instance that executed the command.
158
+
159
+ .. seealso::
160
+ For more information on how to use this operator, take a look at the
161
+ guide:
162
+ :ref:`howto/operator:SsmGetCommandInvocationOperator`
163
+
164
+ :param command_id: The ID of the SSM command to retrieve output for.
165
+ :param instance_id: The ID of the specific instance to retrieve output
166
+ for. If not provided, retrieves output from all instances that
167
+ executed the command.
168
+ :param aws_conn_id: The Airflow connection used for AWS credentials.
169
+ If this is ``None`` or empty then the default boto3 behaviour is used.
170
+ If running Airflow in a distributed manner and aws_conn_id is None or
171
+ empty, then default boto3 configuration would be used (and must be
172
+ maintained on each worker node).
173
+ :param region_name: AWS region_name. If not specified then the default
174
+ boto3 behaviour is used.
175
+ :param verify: Whether or not to verify SSL certificates. See:
176
+ https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html
177
+ :param botocore_config: Configuration dictionary (key-values) for botocore
178
+ client. See:
179
+ https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html
180
+ """
181
+
182
+ aws_hook_class = SsmHook
183
+ template_fields: Sequence[str] = aws_template_fields(
184
+ "command_id",
185
+ "instance_id",
186
+ )
187
+
188
+ def __init__(
189
+ self,
190
+ *,
191
+ command_id: str,
192
+ instance_id: str | None = None,
193
+ **kwargs,
194
+ ):
195
+ super().__init__(**kwargs)
196
+ self.command_id = command_id
197
+ self.instance_id = instance_id
198
+
199
+ def execute(self, context: Context) -> dict[str, Any]:
200
+ """Execute the operator to retrieve command invocation output."""
201
+ if self.instance_id:
202
+ self.log.info(
203
+ "Retrieving output for command %s on instance %s",
204
+ self.command_id,
205
+ self.instance_id,
206
+ )
207
+ invocations = [{"InstanceId": self.instance_id}]
208
+ else:
209
+ self.log.info("Retrieving output for command %s from all instances", self.command_id)
210
+ response = self.hook.list_command_invocations(self.command_id)
211
+ invocations = response.get("CommandInvocations", [])
212
+
213
+ output_data: dict[str, Any] = {"command_id": self.command_id, "invocations": []}
214
+
215
+ for invocation in invocations:
216
+ instance_id = invocation["InstanceId"]
217
+ try:
218
+ invocation_details = self.hook.get_command_invocation(self.command_id, instance_id)
219
+ output_data["invocations"].append(
220
+ {
221
+ "instance_id": instance_id,
222
+ "status": invocation_details.get("Status", ""),
223
+ "response_code": invocation_details.get("ResponseCode", ""),
224
+ "standard_output": invocation_details.get("StandardOutputContent", ""),
225
+ "standard_error": invocation_details.get("StandardErrorContent", ""),
226
+ "execution_start_time": invocation_details.get("ExecutionStartDateTime", ""),
227
+ "execution_end_time": invocation_details.get("ExecutionEndDateTime", ""),
228
+ "document_name": invocation_details.get("DocumentName", ""),
229
+ "comment": invocation_details.get("Comment", ""),
230
+ }
231
+ )
232
+ except Exception as e:
233
+ self.log.warning("Failed to get output for instance %s: %s", instance_id, e)
234
+ output_data["invocations"].append({"instance_id": instance_id, "error": str(e)})
235
+
236
+ return output_data
@@ -22,7 +22,6 @@ from datetime import timedelta
22
22
  from typing import TYPE_CHECKING, Any
23
23
 
24
24
  from airflow.configuration import conf
25
- from airflow.exceptions import AirflowException
26
25
  from airflow.providers.amazon.aws.hooks.step_function import StepFunctionHook
27
26
  from airflow.providers.amazon.aws.links.step_function import (
28
27
  StateMachineDetailsLink,
@@ -32,6 +31,7 @@ from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator
32
31
  from airflow.providers.amazon.aws.triggers.step_function import StepFunctionsExecutionCompleteTrigger
33
32
  from airflow.providers.amazon.aws.utils import validate_execute_complete_event
34
33
  from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
34
+ from airflow.providers.common.compat.sdk import AirflowException
35
35
 
36
36
  if TYPE_CHECKING:
37
37
  from airflow.utils.context import Context
@@ -187,10 +187,9 @@ class SecretsManagerBackend(BaseSecretsBackend, LoggingMixin):
187
187
  }
188
188
 
189
189
  for conn_field, extra_words in self.extra_conn_words.items():
190
- if conn_field == "user":
191
- # Support `user` for backwards compatibility.
192
- conn_field = "login"
193
- possible_words_for_conn_fields[conn_field].extend(extra_words)
190
+ # Support `user` for backwards compatibility.
191
+ conn_field_backcompat = "login" if conn_field == "user" else conn_field
192
+ possible_words_for_conn_fields[conn_field_backcompat].extend(extra_words)
194
193
 
195
194
  conn_d: dict[str, Any] = {}
196
195
  for conn_field, possible_words in possible_words_for_conn_fields.items():
@@ -26,8 +26,8 @@ from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
26
26
  if TYPE_CHECKING:
27
27
  from airflow.utils.context import Context
28
28
 
29
- from airflow.exceptions import AirflowException
30
29
  from airflow.providers.amazon.aws.hooks.athena import AthenaHook
30
+ from airflow.providers.common.compat.sdk import AirflowException
31
31
 
32
32
 
33
33
  class AthenaSensor(AwsBaseSensor[AthenaHook]):
@@ -25,8 +25,8 @@ from airflow.providers.amazon.aws.utils.mixins import (
25
25
  AwsHookType,
26
26
  aws_template_fields,
27
27
  )
28
- from airflow.providers.amazon.version_compat import BaseSensorOperator
29
- from airflow.utils.types import NOTSET, ArgNotSet
28
+ from airflow.providers.amazon.version_compat import NOTSET, ArgNotSet
29
+ from airflow.providers.common.compat.sdk import BaseSensorOperator
30
30
 
31
31
 
32
32
  class AwsBaseSensor(BaseSensorOperator, AwsBaseHookMixin[AwsHookType]):