airflow.providers.amazon.aws.operators.lambda_function

Module Contents

Classes

LambdaCreateFunctionOperator

Creates an AWS Lambda function.

LambdaInvokeFunctionOperator

Invokes an AWS Lambda function.

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

Bases: airflow.models.BaseOperator

Creates an AWS Lambda function.

More information regarding parameters of this operator can be found here https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.create_function

See also

For more information on how to use this operator, take a look at the guide: Create an AWS Lambda function

Parameters
  • function_name (str) – The name of the AWS Lambda function, version, or alias.

  • runtime (str | None) – The identifier of the function’s runtime. Runtime is required if the deployment package is a .zip file archive.

  • role (str) – The Amazon Resource Name (ARN) of the function’s execution role.

  • handler (str | None) – The name of the method within your code that Lambda calls to run your function. Handler is required if the deployment package is a .zip file archive.

  • code (dict) – The code for the function.

  • description (str | None) – A description of the function.

  • timeout (int | None) – The amount of time (in seconds) that Lambda allows a function to run before stopping it.

  • config (dict) – Optional dictionary for arbitrary parameters to the boto API create_lambda call.

  • wait_for_completion (bool) – If True, the operator will wait until the function is active.

  • waiter_max_attempts (int) – Maximum number of attempts to poll the creation.

  • waiter_delay (int) – Number of seconds between polling the state of the creation.

  • deferrable (bool) – If True, the operator will wait asynchronously for the creation to complete. This implies waiting for creation complete. This mode requires aiobotocore module to be installed. (default: False, but can be overridden in config file by setting default_deferrable to True)

  • aws_conn_id (str) – The AWS connection ID to use

template_fields: Sequence[str] = ('function_name', 'runtime', 'role', 'handler', 'code', 'config')[source]
ui_color = '#ff7300'[source]
hook()[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more 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, aws_conn_id='aws_default', **kwargs)[source]

Bases: airflow.models.BaseOperator

Invokes an AWS Lambda function.

You can invoke a function synchronously (and wait for the response), or asynchronously. To invoke a function asynchronously, set invocation_type to Event. For more details, review the boto3 Lambda invoke docs.

See also

For more information on how to use this operator, take a look at the guide: Invoke an AWS Lambda function

Parameters
  • function_name (str) – The name of the AWS Lambda function, version, or alias.

  • log_type (str | None) – Set to Tail to include the execution log in the response and task logs. Otherwise, set to “None”. Applies to synchronously invoked functions only, and returns the last 4 KB of the execution log.

  • keep_empty_log_lines (bool) – Whether or not keep empty lines in the execution log.

  • qualifier (str | None) – Specify a version or alias to invoke a published version of the function.

  • invocation_type (str | None) – AWS Lambda invocation type (RequestResponse, Event, DryRun)

  • client_context (str | None) – Data about the invoking client to pass to the function in the context object

  • payload (bytes | str | None) – JSON provided as input to the Lambda function

  • aws_conn_id (str) – The AWS connection ID to use

template_fields: Sequence[str] = ('function_name', 'payload', 'qualifier', 'invocation_type')[source]
ui_color = '#ff7300'[source]
hook()[source]
execute(context)[source]

Invoke the target AWS Lambda function from Airflow.

Returns

The response payload from the function, or an error object.

Was this entry helpful?