airflow.providers.amazon.aws.operators.ec2

EC2StartInstanceOperator

使用 boto3 启动 AWS EC2 实例。

EC2StopInstanceOperator

使用 boto3 停止 AWS EC2 实例。

EC2CreateInstanceOperator

使用 boto3 创建并启动指定数量的 EC2 实例。

EC2TerminateInstanceOperator

使用 boto3 终止 EC2 实例。

EC2RebootInstanceOperator

重启 Amazon EC2 实例。

EC2HibernateInstanceOperator

休眠 Amazon EC2 实例。

模块内容

class airflow.providers.amazon.aws.operators.ec2.EC2StartInstanceOperator(*, instance_id, check_interval=15, **kwargs)[source]

基类: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.ec2.EC2Hook]

使用 boto3 启动 AWS EC2 实例。

另请参阅

有关如何使用此操作符的更多信息,请查阅以下指南: 启动 Amazon EC2 实例

参数::
  • instance_id (str) – AWS EC2 实例 ID :param aws_conn_id: 用于 AWS 凭据的 Airflow 连接。如果此参数为 None 或空,则使用默认的 boto3 行为。如果以分布式方式运行 Airflow 且 aws_conn_id 为 None 或空,则使用默认的 boto3 配置(并且必须在每个 worker 节点上维护此配置)。

  • region_name – AWS 区域名称。如果未指定,则使用默认的 boto3 行为。

  • verify – 是否验证 SSL 证书。参阅: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • check_interval (float) – 作业在每次实例状态检查之间应等待的秒数,直到操作完成

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
ui_color = '#eeaa11'[source]
ui_fgcolor = '#ffffff'[source]
instance_id[source]
check_interval = 15[source]
execute(context)[source]

创建操作符时派生。

上下文是与渲染 jinja 模板时使用的相同的字典。

有关更多上下文信息,请参阅 get_template_context。

class airflow.providers.amazon.aws.operators.ec2.EC2StopInstanceOperator(*, instance_id, check_interval=15, **kwargs)[source]

基类: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.ec2.EC2Hook]

使用 boto3 停止 AWS EC2 实例。

另请参阅

有关如何使用此操作符的更多信息,请查阅以下指南: 停止 Amazon EC2 实例

参数::
  • instance_id (str) – AWS EC2 实例 ID

  • aws_conn_id – 用于 AWS 凭据的 Airflow 连接。如果此参数为 None 或空,则使用默认的 boto3 行为。如果以分布式方式运行 Airflow 且 aws_conn_id 为 None 或空,则使用默认的 boto3 配置(并且必须在每个 worker 节点上维护此配置)。

  • region_name – AWS 区域名称。如果未指定,则使用默认的 boto3 行为。

  • verify – 是否验证 SSL 证书。参阅: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • check_interval (float) – 作业在每次实例状态检查之间应等待的秒数,直到操作完成

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
ui_color = '#eeaa11'[source]
ui_fgcolor = '#ffffff'[source]
instance_id[source]
check_interval = 15[source]
execute(context)[source]

创建操作符时派生。

上下文是与渲染 jinja 模板时使用的相同的字典。

有关更多上下文信息,请参阅 get_template_context。

class airflow.providers.amazon.aws.operators.ec2.EC2CreateInstanceOperator(image_id, max_count=1, min_count=1, poll_interval=20, max_attempts=20, config=None, wait_for_completion=False, **kwargs)[source]

基类: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.ec2.EC2Hook]

使用 boto3 创建并启动指定数量的 EC2 实例。

另请参阅

有关如何使用此操作符的更多信息,请查阅以下指南: 创建并启动 Amazon EC2 实例

参数::
  • image_id (str) – 用于创建实例的 AMI ID。

  • max_count (int) – 要启动的最大实例数。默认为 1。

  • min_count (int) – 要启动的最小实例数。默认为 1。

  • aws_conn_id – 用于 AWS 凭据的 Airflow 连接。如果此参数为 None 或空,则使用默认的 boto3 行为。如果以分布式方式运行 Airflow 且 aws_conn_id 为 None 或空,则使用默认的 boto3 配置(并且必须在每个 worker 节点上维护此配置)。

  • region_name – AWS 区域名称。如果未指定,则使用默认的 boto3 行为。

  • verify – 是否验证 SSL 证书。参阅: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • poll_interval (int) – 尝试检查实例状态前等待的秒数。仅在 wait_for_completion 为 True 时使用。默认为 20。

  • max_attempts (int) – 检查实例状态时的最大尝试次数。仅在 wait_for_completion 为 True 时使用。默认为 20。

  • config (dict | None) – boto3 run_instances 调用的任意参数字典。

  • wait_for_completion (bool) – 如果为 True,操作符将在实例处于 running 状态后返回。

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
image_id[source]
max_count = 1[source]
min_count = 1[source]
poll_interval = 20[source]
max_attempts = 20[source]
config[source]
wait_for_completion = False[source]
execute(context)[source]

创建操作符时派生。

上下文是与渲染 jinja 模板时使用的相同的字典。

有关更多上下文信息,请参阅 get_template_context。

on_kill()[source]

当任务实例被终止时,重写此方法以清理子进程。

在操作符中使用 threading、subprocess 或 multiprocessing 模块时,都需要进行清理,否则会留下僵尸进程。

class airflow.providers.amazon.aws.operators.ec2.EC2TerminateInstanceOperator(instance_ids, poll_interval=20, max_attempts=20, wait_for_completion=False, **kwargs)[source]

基类: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.ec2.EC2Hook]

使用 boto3 终止 EC2 实例。

另请参阅

有关如何使用此操作符的更多信息,请查阅以下指南: 终止 Amazon EC2 实例

参数::
  • instance_id – 要终止的实例 ID。

  • aws_conn_id – 用于 AWS 凭据的 Airflow 连接。如果此参数为 None 或空,则使用默认的 boto3 行为。如果以分布式方式运行 Airflow 且 aws_conn_id 为 None 或空,则使用默认的 boto3 配置(并且必须在每个 worker 节点上维护此配置)。

  • region_name – AWS 区域名称。如果未指定,则使用默认的 boto3 行为。

  • verify – 是否验证 SSL 证书。参阅: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • poll_interval (int) – 尝试检查实例状态前等待的秒数。仅在 wait_for_completion 为 True 时使用。默认为 20。

  • max_attempts (int) – 检查实例状态时的最大尝试次数。仅在 wait_for_completion 为 True 时使用。默认为 20。

  • wait_for_completion (bool) – 如果为 True,操作符将在实例处于 terminated 状态后返回。

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
instance_ids[source]
poll_interval = 20[source]
max_attempts = 20[source]
wait_for_completion = False[source]
execute(context)[source]

创建操作符时派生。

上下文是与渲染 jinja 模板时使用的相同的字典。

有关更多上下文信息,请参阅 get_template_context。

class airflow.providers.amazon.aws.operators.ec2.EC2RebootInstanceOperator(*, instance_ids, poll_interval=20, max_attempts=20, wait_for_completion=False, **kwargs)[source]

基类: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.ec2.EC2Hook]

重启 Amazon EC2 实例。

另请参阅

有关如何使用此操作符的更多信息,请查阅以下指南: 重启 Amazon EC2 实例

参数::
  • instance_ids (str | list[str]) – 要重启的实例 ID(或多个 ID)。

  • aws_conn_id – 用于 AWS 凭据的 Airflow 连接。如果此参数为 None 或空,则使用默认的 boto3 行为。如果以分布式方式运行 Airflow 且 aws_conn_id 为 None 或空,则使用默认的 boto3 配置(并且必须在每个 worker 节点上维护此配置)。

  • region_name – AWS 区域名称。如果未指定,则使用默认的 boto3 行为。

  • verify – 是否验证 SSL 证书。参阅: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • poll_interval (int) – 尝试检查实例状态前等待的秒数。仅在 wait_for_completion 为 True 时使用。默认为 20。

  • max_attempts (int) – 检查实例状态时的最大尝试次数。仅在 wait_for_completion 为 True 时使用。默认为 20。

  • wait_for_completion (bool) – 如果为 True,操作符将在实例处于 running 状态后返回。

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
ui_color = '#eeaa11'[source]
ui_fgcolor = '#ffffff'[source]
instance_ids[source]
poll_interval = 20[source]
max_attempts = 20[source]
wait_for_completion = False[source]
execute(context)[source]

创建操作符时派生。

上下文是与渲染 jinja 模板时使用的相同的字典。

有关更多上下文信息,请参阅 get_template_context。

class airflow.providers.amazon.aws.operators.ec2.EC2HibernateInstanceOperator(*, instance_ids, poll_interval=20, max_attempts=20, wait_for_completion=False, **kwargs)[source]

基类: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.ec2.EC2Hook]

休眠 Amazon EC2 实例。

另请参阅

有关如何使用此操作符的更多信息,请查阅以下指南: 休眠 Amazon EC2 实例

参数::
  • instance_ids (str | list[str]) – 要休眠的实例 ID(或多个 ID)。

  • aws_conn_id – 用于 AWS 凭据的 Airflow 连接。如果此参数为 None 或空,则使用默认的 boto3 行为。如果以分布式方式运行 Airflow 且 aws_conn_id 为 None 或空,则使用默认的 boto3 配置(并且必须在每个 worker 节点上维护此配置)。

  • region_name – AWS 区域名称。如果未指定,则使用默认的 boto3 行为。

  • verify – 是否验证 SSL 证书。参阅: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • poll_interval (int) – 尝试检查实例状态前等待的秒数。仅在 wait_for_completion 为 True 时使用。默认为 20。

  • max_attempts (int) – 检查实例状态时的最大尝试次数。仅在 wait_for_completion 为 True 时使用。默认为 20。

  • wait_for_completion (bool) – 如果为 True,操作符将在实例处于 stopped 状态后返回。

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
ui_color = '#eeaa11'[source]
ui_fgcolor = '#ffffff'[来源]
instance_ids[来源]
poll_interval = 20[来源]
max_attempts = 20[来源]
wait_for_completion = False[来源]
execute(context)[来源]

创建操作符时派生。

上下文是与渲染 jinja 模板时使用的相同的字典。

有关更多上下文信息,请参阅 get_template_context。

此条目是否有帮助?