airflow.providers.amazon.aws.operators.lambda_function

LambdaCreateFunctionOperator

建立一個 AWS Lambda 函式。

LambdaInvokeFunctionOperator

呼叫一個 AWS Lambda 函式。

模組內容

class airflow.providers.amazon.aws.operators.lambda_function.LambdaCreateFunctionOperator(*, function_name, runtime=None, role, handler=None, code, description=None, timeout=None, config=None, wait_for_completion=False, waiter_max_attempts=60, waiter_delay=15, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]

Bases: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.lambda_function.LambdaHook]

建立一個 AWS Lambda 函式。

有關此 Operator 引數的更多資訊,請參見此處 https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.create_function

另請參閱

有關如何使用此 Operator 的更多資訊,請參閱指南:建立 AWS Lambda 函式

引數:
  • function_name (str) – AWS Lambda 函式、版本或別名的名稱。

  • runtime (str | None) – 函式執行時的識別符號。如果部署包是 .zip 檔案歸檔,則執行時是必需的。

  • role (str) – 函式執行角色的 Amazon Resource Name (ARN)。

  • handler (str | None) – Lambda 呼叫以執行您的函式的方法名稱。如果部署包是 .zip 檔案歸檔,則 Handler 是必需的。

  • code (dict) – 函式程式碼。

  • description (str | None) – 函式描述。

  • timeout (int | None) – Lambda 允許函式執行直到停止的時間量(以秒為單位)。

  • config (dict | None) – 用於向 boto API create_lambda 呼叫傳遞任意引數的可選字典。

  • wait_for_completion (bool) – 如果為 True,Operator 將等待函式變為活躍狀態。

  • waiter_max_attempts (int) – 輪詢建立狀態的最大嘗試次數。

  • waiter_delay (int) – 兩次輪詢建立狀態之間的間隔(以秒為單位)。

  • deferrable (bool) – 如果為 True,Operator 將非同步等待建立完成。這意味著需要等待建立完成。此模式需要安裝 aiobotocore 模組。(預設為 False,但可以在配置檔案中設定 default_deferrable 為 True 來覆蓋)

  • aws_conn_id – 要使用的 AWS 連線 ID

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
ui_color = '#ff7300'[source]
function_name[source]
runtime = None[source]
role[source]
handler = None[source]
code[source]
description = None[source]
timeout = None[source]
config[source]
wait_for_completion = False[source]
waiter_delay = 15[source]
waiter_max_attempts = 60[source]
deferrable = True[source]
execute(context)[source]

建立 Operator 時派生。

Context 是渲染 jinja 模板時使用的相同字典。

有關更多 context,請參閱 get_template_context。

execute_complete(context, event=None)[source]
class airflow.providers.amazon.aws.operators.lambda_function.LambdaInvokeFunctionOperator(*, function_name, log_type=None, keep_empty_log_lines=True, qualifier=None, invocation_type=None, client_context=None, payload=None, **kwargs)[source]

Bases: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.lambda_function.LambdaHook]

呼叫一個 AWS Lambda 函式。

您可以同步(並等待響應)或非同步呼叫函式。要非同步呼叫函式,請將 invocation_type 設定為 Event。有關更多詳細資訊,請查閱 boto3 Lambda invoke 文件。

另請參閱

有關如何使用此 Operator 的更多資訊,請參閱指南:呼叫 AWS Lambda 函式

引數:
  • function_name (str) – AWS Lambda 函式、版本或別名的名稱。

  • log_type (str | None) – 設定為 Tail 以在響應和任務日誌中包含執行日誌。否則,設定為 “None”。僅適用於同步呼叫的函式,並返回執行日誌的最後 4 KB。

  • keep_empty_log_lines (bool) – 是否保留執行日誌中的空行。

  • qualifier (str | None) – 指定版本或別名以呼叫函式的已釋出版本。

  • invocation_type (str | None) – AWS Lambda 呼叫型別 (RequestResponse, Event, DryRun)

  • client_context (str | None) – 關於呼叫客戶端的資料,將傳遞給函式的 context 物件

  • payload (bytes | str | None) – 作為輸入提供給 Lambda 函式的 JSON

  • aws_conn_id – 要使用的 AWS 連線 ID

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
ui_color = '#ff7300'[source]
function_name[source]
payload = None[source]
log_type = None[source]
keep_empty_log_lines = True[source]
qualifier = None[source]
invocation_type = None[source]
client_context = None[source]
execute(context)[source]

從 Airflow 呼叫目標 AWS Lambda 函式。

返回:

函式的響應 payload 或錯誤物件。

此條目有幫助嗎?