airflow.providers.amazon.aws.hooks.lambda_function

This module contains AWS Lambda hook.

Module Contents

Classes

LambdaHook

Interact with AWS Lambda.

class airflow.providers.amazon.aws.hooks.lambda_function.LambdaHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with AWS Lambda.

Provide thin wrapper around boto3.client("lambda").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

invoke_lambda(*, function_name, invocation_type=None, log_type=None, client_context=None, payload=None, qualifier=None)[source]

Invoke Lambda Function.

Parameters
  • function_name (str) – AWS Lambda Function Name

  • invocation_type (str | None) – AWS Lambda Invocation Type (RequestResponse, Event etc)

  • log_type (str | None) – Set to Tail to include the execution log in the response. Applies to synchronously invoked functions only.

  • client_context (str | None) – Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object.

  • payload (bytes | str | None) – The JSON that you want to provide to your Lambda function as input.

  • qualifier (str | None) – AWS Lambda Function Version or Alias Name

create_lambda(*, function_name, runtime=None, role, handler=None, code, description=None, timeout=None, memory_size=None, publish=None, vpc_config=None, package_type=None, dead_letter_config=None, environment=None, kms_key_arn=None, tracing_config=None, tags=None, layers=None, file_system_configs=None, image_config=None, code_signing_config_arn=None, architectures=None)[source]

Create a Lambda function.

Parameters
  • function_name (str) – AWS Lambda Function Name

  • 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.

  • memory_size (int | None) – The amount of memory available to the function at runtime. Increasing the function memory also increases its CPU allocation.

  • publish (bool | None) – Set to true to publish the first version of the function during creation.

  • vpc_config (Any | None) – For network connectivity to Amazon Web Services resources in a VPC, specify a list of security groups and subnets in the VPC.

  • package_type (str | None) – The type of deployment package. Set to Image for container image and set to Zip for .zip file archive.

  • dead_letter_config (Any | None) – A dead-letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing.

  • environment (Any | None) – Environment variables that are accessible from function code during execution.

  • kms_key_arn (str | None) – The ARN of the Key Management Service (KMS) key that’s used to encrypt your function’s environment variables. If it’s not provided, Lambda uses a default service key.

  • tracing_config (Any | None) – Set Mode to Active to sample and trace a subset of incoming requests with X-Ray.

  • tags (Any | None) – A list of tags to apply to the function.

  • layers (list | None) – A list of function layers to add to the function’s execution environment. Specify each layer by its ARN, including the version.

  • file_system_configs (list[Any] | None) – Connection settings for an Amazon EFS file system.

  • image_config (Any | None) – Container image configuration values that override the values in the container image Dockerfile.

  • code_signing_config_arn (str | None) – To enable code signing for this function, specify the ARN of a code-signing configuration. A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.

  • architectures (list[str] | None) – The instruction set architecture that the function supports.

static encode_log_result(log_result, *, keep_empty_lines=True)[source]

Encode execution log from the response and return list of log records.

Returns None on error, e.g. invalid base64-encoded string

Parameters
  • log_result (str) – base64-encoded string which contain Lambda execution Log.

  • keep_empty_lines (bool) – Whether or not keep empty lines.

Was this entry helpful?