aws_ddk_core.resources.LambdaFactory¶
- class aws_ddk_core.resources.LambdaFactory¶
Class factory to create and configure Lambda DDK resources, including Functions.
- __init__()¶
Methods
__init__
()add_vpc_permissions
(fn)function
(scope, id, environment_id, code, ...)Create and configure Lambda function.
- static function(scope: constructs.Construct, id: str, environment_id: str, code: aws_cdk.aws_lambda.Code, handler: str, runtime: aws_cdk.aws_lambda.Runtime = <aws_cdk.aws_lambda.Runtime object>, function_name: typing.Optional[str] = None, description: typing.Optional[str] = None, role: typing.Optional[aws_cdk.aws_iam.IRole] = None, dead_letter_queue_enabled: typing.Optional[bool] = None, dead_letter_queue: typing.Optional[aws_cdk.aws_sqs.IQueue] = None, memory_size: typing.Optional[int] = None, timeout: typing.Optional[aws_cdk.Duration] = None, **function_props: typing.Any) aws_cdk.aws_lambda.IFunction ¶
Create and configure Lambda function.
This construct allows to configure parameters of the function using ddk.json configuration file depending on the environment_id in which the function is used. Supported parameters are: dead_letter_queue_enabled,`memory_size`, environment, profiling, reserved_concurrent_executions, timeout, tracing, max_event_age, retry_attempts, allow_all_outbound, and allow_public_subnet.
The parameters are respected in the following order: 1 - Explicit arguments are always preferred 2 - Values from configuration file 3 - Defaults are used otherwise
- Parameters
scope (Construct) – Scope within which this construct is defined
id (str) – Identifier of the Lambda function
environment_id (str) – Identifier of the environment
code (Code) – The source code of the Lambda function
handler (str) – The name of the method within the code that Lambda calls to execute the function
runtime (Runtime) – The runtime environment for the Lambda function
function_name (Optional[str]) – The name of the Lambda function
description (Optional[str]) – The description of the Lambda function
role (Optional[IRole]) – Lambda execution role
dead_letter_queue_enabled (Optional[bool]) – Determines if DLQ is enabled. False by default.
dead_letter_queue (Optional[IQueue]) – The SQS queue to use if DLQ is enabled
memory_size (Optional[int]) – The amount of memory, in MB, that is allocated to the Lambda function. 256 by default.
timeout (Optional[Duration]) – The function execution time (in seconds) after which Lambda terminates the function. aws_cdk.Duration.seconds(120) by default.
function_props (Any) – Additional function properties. For complete list of properties refer to CDK Documentation - Lambda Function: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_lambda/Function.html
- Returns
fn – Lambda function
- Return type
aws_cdk.aws_lambda.Function