airflow.providers.amazon.aws.triggers.ecs

Module Contents

Classes

ClusterActiveTrigger

Polls the status of a cluster until it's active.

ClusterInactiveTrigger

Polls the status of a cluster until it's inactive.

TaskDoneTrigger

Waits for an ECS task to be done, while eventually polling logs.

class airflow.providers.amazon.aws.triggers.ecs.ClusterActiveTrigger(cluster_arn, waiter_delay, waiter_max_attempts, aws_conn_id, region_name)[source]

Bases: airflow.providers.amazon.aws.triggers.base.AwsBaseWaiterTrigger

Polls the status of a cluster until it’s active.

Parameters
  • cluster_arn (str) – ARN of the cluster to watch.

  • waiter_delay (int) – The amount of time in seconds to wait between attempts.

  • waiter_max_attempts (int) – The number of times to ping for status. Will fail after that many unsuccessful attempts.

  • aws_conn_id (str | None) – The Airflow connection used for AWS credentials.

  • region_name (str | None) – The AWS region where the cluster is located.

hook()[source]

Override in subclasses to return the right hook.

class airflow.providers.amazon.aws.triggers.ecs.ClusterInactiveTrigger(cluster_arn, waiter_delay, waiter_max_attempts, aws_conn_id, region_name)[source]

Bases: airflow.providers.amazon.aws.triggers.base.AwsBaseWaiterTrigger

Polls the status of a cluster until it’s inactive.

Parameters
  • cluster_arn (str) – ARN of the cluster to watch.

  • waiter_delay (int) – The amount of time in seconds to wait between attempts.

  • waiter_max_attempts (int) – The number of times to ping for status. Will fail after that many unsuccessful attempts.

  • aws_conn_id (str | None) – The Airflow connection used for AWS credentials.

  • region_name (str | None) – The AWS region where the cluster is located.

hook()[source]

Override in subclasses to return the right hook.

class airflow.providers.amazon.aws.triggers.ecs.TaskDoneTrigger(cluster, task_arn, waiter_delay, waiter_max_attempts, aws_conn_id, region, log_group=None, log_stream=None)[source]

Bases: airflow.triggers.base.BaseTrigger

Waits for an ECS task to be done, while eventually polling logs.

Parameters
  • cluster (str) – short name or full ARN of the cluster where the task is running.

  • task_arn (str) – ARN of the task to watch.

  • waiter_delay (int) – The amount of time in seconds to wait between attempts.

  • waiter_max_attempts (int) – The number of times to ping for status. Will fail after that many unsuccessful attempts.

  • aws_conn_id (str | None) – The Airflow connection used for AWS credentials.

  • region (str | None) – The AWS region where the cluster is located.

serialize()[source]

Returns the information needed to reconstruct this Trigger.

Returns

Tuple of (class path, keyword arguments needed to re-instantiate).

Return type

tuple[str, dict[str, Any]]

async run()[source]

Runs the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

Was this entry helpful?