This is an automated email from the ASF dual-hosted git repository.
eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 0b1912c1061 Propagate verify and botocore_config through
EC2StateSensorTrigger (#68921)
0b1912c1061 is described below
commit 0b1912c10612ad4cea3923f47cb638c65c14ebdb
Author: Niko Oliveira <[email protected]>
AuthorDate: Wed Jun 24 08:52:26 2026 -0700
Propagate verify and botocore_config through EC2StateSensorTrigger (#68921)
EC2StateSensorTrigger now accepts and serializes verify and botocore_config
and
builds its hook with them, and EC2InstanceStateSensor forwards those values
when
deferring. Previously a deferred EC2InstanceStateSensor silently dropped SSL
verification and botocore configuration, completing the trigger portion of
the
EC2 migration in apache/airflow#35278.
---
.../airflow/providers/amazon/aws/sensors/ec2.py | 2 ++
.../airflow/providers/amazon/aws/triggers/ec2.py | 16 +++++++++++++++-
.../tests/unit/amazon/aws/triggers/test_ec2.py | 22 ++++++++++++++++++++++
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/providers/amazon/src/airflow/providers/amazon/aws/sensors/ec2.py
b/providers/amazon/src/airflow/providers/amazon/aws/sensors/ec2.py
index d5d2929d10c..404b40e59e4 100644
--- a/providers/amazon/src/airflow/providers/amazon/aws/sensors/ec2.py
+++ b/providers/amazon/src/airflow/providers/amazon/aws/sensors/ec2.py
@@ -75,6 +75,8 @@ class EC2InstanceStateSensor(AwsBaseSensor[EC2Hook]):
aws_conn_id=self.aws_conn_id,
region_name=self.region_name,
poll_interval=int(self.poke_interval),
+ verify=self.verify,
+ botocore_config=self.botocore_config,
),
method_name="execute_complete",
)
diff --git a/providers/amazon/src/airflow/providers/amazon/aws/triggers/ec2.py
b/providers/amazon/src/airflow/providers/amazon/aws/triggers/ec2.py
index 9346e86caf7..8b2d4d98af8 100644
--- a/providers/amazon/src/airflow/providers/amazon/aws/triggers/ec2.py
+++ b/providers/amazon/src/airflow/providers/amazon/aws/triggers/ec2.py
@@ -37,6 +37,8 @@ class EC2StateSensorTrigger(BaseTrigger):
maintained on each worker node).
:param region_name: (optional) aws region name associated with the client
:param poll_interval: number of seconds to wait before attempting the next
poll
+ :param verify: Whether or not to verify SSL certificates. Used to build
the hook.
+ :param botocore_config: Configuration dictionary for the botocore client.
Used to build the hook.
"""
def __init__(
@@ -46,12 +48,16 @@ class EC2StateSensorTrigger(BaseTrigger):
aws_conn_id: str | None = "aws_default",
region_name: str | None = None,
poll_interval: int = 60,
+ verify: bool | str | None = None,
+ botocore_config: dict | None = None,
):
self.instance_id = instance_id
self.target_state = target_state
self.aws_conn_id = aws_conn_id
self.region_name = region_name
self.poll_interval = poll_interval
+ self.verify = verify
+ self.botocore_config = botocore_config
def serialize(self) -> tuple[str, dict[str, Any]]:
return (
@@ -62,12 +68,20 @@ class EC2StateSensorTrigger(BaseTrigger):
"aws_conn_id": self.aws_conn_id,
"region_name": self.region_name,
"poll_interval": self.poll_interval,
+ "verify": self.verify,
+ "botocore_config": self.botocore_config,
},
)
@cached_property
def hook(self):
- return EC2Hook(aws_conn_id=self.aws_conn_id,
region_name=self.region_name, api_type="client_type")
+ return EC2Hook(
+ aws_conn_id=self.aws_conn_id,
+ region_name=self.region_name,
+ verify=self.verify,
+ config=self.botocore_config,
+ api_type="client_type",
+ )
async def run(self):
while True:
diff --git a/providers/amazon/tests/unit/amazon/aws/triggers/test_ec2.py
b/providers/amazon/tests/unit/amazon/aws/triggers/test_ec2.py
index c91b8ecf62e..cf87fbdf2d5 100644
--- a/providers/amazon/tests/unit/amazon/aws/triggers/test_ec2.py
+++ b/providers/amazon/tests/unit/amazon/aws/triggers/test_ec2.py
@@ -48,6 +48,28 @@ class TestEC2StateSensorTrigger:
assert args["aws_conn_id"] == TEST_CONN_ID
assert args["region_name"] == TEST_REGION_NAME
assert args["poll_interval"] == TEST_POLL_INTERVAL
+ assert args["verify"] is None
+ assert args["botocore_config"] is None
+
+ def test_ec2_state_sensor_trigger_serializes_generic_hook_params(self):
+ test_ec2_state_sensor = EC2StateSensorTrigger(
+ instance_id=TEST_INSTANCE_ID,
+ target_state=TEST_TARGET_STATE,
+ aws_conn_id=TEST_CONN_ID,
+ region_name=TEST_REGION_NAME,
+ poll_interval=TEST_POLL_INTERVAL,
+ verify=False,
+ botocore_config={"read_timeout": 99},
+ )
+ _, args = test_ec2_state_sensor.serialize()
+ assert args["verify"] is False
+ assert args["botocore_config"] == {"read_timeout": 99}
+
+ hook = test_ec2_state_sensor.hook
+ assert hook.aws_conn_id == TEST_CONN_ID
+ assert hook._region_name == TEST_REGION_NAME
+ assert hook._verify is False
+ assert hook._config.read_timeout == 99
@pytest.mark.asyncio
@mock.patch("airflow.providers.amazon.aws.hooks.ec2.EC2Hook.get_instance_state_async")